offlinemark/poet

add build system support for optimized bytecode

Closed this issue · 2 comments

we can specify -O when running py_compile to generate optimized pyo files that include less debug info (harder to reverse engineer). i was having trouble writing the makefile that would support this with multiple targets though

ok, after playing around some more here's what I've learned

  • no matter what, packaging stuff into zip files and running that removes the ability to get source in pdb

http://stackoverflow.com/questions/17475035/what-is-the-difference-between-pyc-and-pyo-files-in-python

testing:

-OO

-rw-r--r--  1 mark  staff  8432 Mar 28 16:11 __main__.pyo
-rw-r--r--  1 mark  staff  5349 Mar 28 16:11 poet-client.zip
-rw-r--r--  1 mark  staff  6384 Mar 28 16:11 poet-server.zip
-rw-r--r--  1 mark  staff  1885 Mar 28 16:11 poetsocket.pyo

-O

-rw-r--r--  1 mark  staff  10139 Mar 28 16:07 __main__.pyo
-rw-r--r--  1 mark  staff   6342 Mar 28 16:07 poet-client.zip
-rw-r--r--  1 mark  staff   7163 Mar 28 16:07 poet-server.zip
-rw-r--r--  1 mark  staff   2308 Mar 28 16:07 poetsocket.pyo


-rw-r--r--  1 mark  staff  10139 Mar 28 16:08 __main__.pyc
-rw-r--r--  1 mark  staff   6342 Mar 28 16:08 poet-client.zip
-rw-r--r--  1 mark  staff   7163 Mar 28 16:08 poet-server.zip
-rw-r--r--  1 mark  staff   2308 Mar 28 16:08 poetsocket.pyc

seems like compiling with and without -O are exactly the same. however -OO introduces differences. also based from debugging, it seems like line numbers are always present (says ipdb), docstrings are gone in -OO