PDA

View Full Version : Update on my progress with Python and compression


riskable
06-04-2009, 06:40 AM
I've just about got my (incomplete) rough draft ready for submission and I thought I'd post an update regarding my compression/size reduction milestones. I know some of the folks on this board will find this information interesting...

I've already posted publicly my Python code minifier (http://code.activestate.com/recipes/576704/) and my CherryPy compressed tarball recipe (http://code.activestate.com/recipes/576706/) but I wanted to mention some extra tidbits others will likely find useful:

* Mako templates that other templates inherit cannot be served from within a compressed archive. This is due to the way Mako works and cannot be fixed (as far as I know). I have added, "Python template engine that works with compression" to my long-term TODO list. There may be template systems out there that can be served from within archive files but I don't have the time to research it right now.
* GNU gettext .mo files also cannot be served from within compressed archives. However, if I have time I believe I can write an alternate gettext module for Python embedded developers that *can* access .mo files inside of an archive. Any Python developer could probably come up with such a module in a few days of spare time (hint: anyone have time?). This really messed up my nice-and-clean plugin system layout :P
* It isn't necessary to zip up each individual module you want to import into your Python program. You can just include them all into one giant zip archive and append that archive to the sys.path. Not a big deal but the less files in the built version the better.

Finally, I'll end this post with the output of my build script which shows how much space is saved in the process of compressing everything that can be compressed:

$ ./build.sh
SPACE BEFORE: 5.0M .
SPACE AFTER: 396K build

No, that 5.0M doesn't include the 396k build dir :)

UBNT-Robert
06-14-2009, 01:01 AM
Hi Riskable,

Sounds interesting. Definitely you can post some screenshots.


Robert

CzechEnglishFrenchGermanItalianPolishPortugueseRussianSpanish
Translated to other languages supported by vB Enterprise Translator 3.5.4