The Following 12 Users Say Thank You to Jaffa For This Useful Post: | ||
attila77, CrashandDie, frals, Helmuth, lcuk, lma, mbo, MohammadAG, noobmonkey, Slocan, Texrat, zimon |
|
2010-04-26
, 07:17
|
Posts: 3,319 |
Thanked: 5,610 times |
Joined on Aug 2008
@ Finland
|
#32
|
|
2010-04-26
, 11:38
|
Posts: 152 |
Thanked: 620 times |
Joined on Mar 2008
@ Netherlands
|
#33
|
|
2010-04-26
, 11:51
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#34
|
Precompiling should save quite a lot on parsing as it needs to simple read less bytes from storage and doesn't have to do the parse part.
|
2010-04-26
, 15:55
|
Posts: 87 |
Thanked: 47 times |
Joined on Sep 2009
@ Sorocaba, Brasil
|
#35
|
An alternative for handling this ^ is in the postinst/postrm script on the device, that way the debs are kept smaller and apt needs to track less files (at the cost of doing that yourself and a longer install time). Plus, should a system update be shipped with a pyc incompatible Python version, reinstalling the packages updates the pyc/pyo-s without any maintainer intervention.
2.6 Modules Byte-Compilation
If a binary package provides any binary-independent modules (foo.py files), the corresponding byte-compiled modules (foo.pyc files) and optimized modules (foo.pyo files) must not ship in the package. Instead, they should be generated in the package's postinst, and removed in the package's prerm. The package's prerm has to make sure that both foo.pyc and foo.pyo are removed.
A binary package should only byte-compile the files which belong to the package.
The file /etc/python/debian_config allows configuration how modules should be byte-compiled. The postinst scripts should respect these settings.
Pure Python modules in private installation directories that are byte-compiled with the default Python version must be forcefully byte-compiled again when the default Python version changes. Public Python extensions should be bin-NMUed. Private Python extensions should be subject to binary NMUs every time the default interpreter changes, unless the extension is updated through a .rtupdate script.
|
2010-04-26
, 16:01
|
|
Posts: 1,684 |
Thanked: 1,562 times |
Joined on Jun 2008
@ Austin, TX
|
#36
|
noobmonk3y - so you just saved 20% of the load time by scrubbing your code?
thats remarkable (tho extreme, we like comments)
i did not expect the difference to be so great.
if we could strip them from debs as part of packaging for most python apps that would be wicked
(keep them in source of course)
|
2010-04-26
, 16:08
|
|
Posts: 11,700 |
Thanked: 10,045 times |
Joined on Jun 2006
@ North Texas, USA
|
#37
|
The Following User Says Thank You to Texrat For This Useful Post: | ||
|
2010-04-26
, 16:25
|
Posts: 1,341 |
Thanked: 708 times |
Joined on Feb 2010
|
#38
|
Public Python extensions should be bin-NMUed. Private Python extensions should be subject to binary NMUs every time the default interpreter changes, unless the extension is updated through a .rtupdate script.
|
2010-04-26
, 16:33
|
Posts: 1,341 |
Thanked: 708 times |
Joined on Feb 2010
|
#39
|
A problem with scrubbing files is when I get a log from my users with a traceback, I have to do extra hunting to figure out what code caused the exception.
|
2010-04-26
, 16:48
|
Posts: 3,319 |
Thanked: 5,610 times |
Joined on Aug 2008
@ Finland
|
#40
|
What is NMU?
The Following User Says Thank You to attila77 For This Useful Post: | ||
Tags |
performance, python |
|
I haven't done any performance testing, but if packagers don't do this, and the Python app is being run as user (and it's installed in /opt or /usr), Python will have to do parsing every time: it won't be able to write the bytecode back to disk for next time, as "user" usually won't have permission to the install directory.
Andrew Flegg -- mailto:andrew@bleb.org | http://www.bleb.org