Active Topics

 


Reply
Thread Tools
Jaffa's Avatar
Posts: 2,535 | Thanked: 6,681 times | Joined on Mar 2008 @ UK
#31
Originally Posted by epage View Post
I can't say off of a benchmark but comments affect parsing. If pyc (or even better?) pyo files are already generated, stored, and run then comments shouldn't matter.
As part of Hermes' Makefile I have:

Code:
compile:
    py_compilefiles src/*.py
This should pre-compile "Python .py source files into .pyc or .pyo bytecode format."

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
 

The Following 12 Users Say Thank You to Jaffa For This Useful Post:
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#32
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.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 

The Following 3 Users Say Thank You to attila77 For This Useful Post:
Posts: 152 | Thanked: 620 times | Joined on Mar 2008 @ Netherlands
#33
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.
__________________
http://maemo.org/profile/view/xfade/ - maemo.org webmaster Apps.formeego.org (Apps for N9)
 

The Following 2 Users Say Thank You to X-Fade For This Useful Post:
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#34
Originally Posted by X-Fade View Post
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.
Precompiled code in an evaluated environment speeds up loading a great deal.

But remember that the time it took to start the program always gets spread out over how long time you actually use the program. 10s to start for an application that you use 2s (for example getting temperature data from your favourite source and displaying it) is painful. 10s to start for an application that you use for 20m is something quite different.

But sure, it's always nice when applications start almost before you knew you wanted to use them.
 

The Following 2 Users Say Thank You to Joorin For This Useful Post:
Posts: 87 | Thanked: 47 times | Joined on Sep 2009 @ Sorocaba, Brasil
#35
Originally Posted by attila77 View Post
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.
This matches what's in the Debian Python Policy, as well:

http://www.debian.org/doc/packaging-..._packages.html

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.
 

The Following 9 Users Say Thank You to dalonso For This Useful Post:
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#36
Originally Posted by lcuk View Post
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)
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.

Prioritize this nugget wherever you want.
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 

The Following 3 Users Say Thank You to epage For This Useful Post:
Texrat's Avatar
Posts: 11,700 | Thanked: 10,045 times | Joined on Jun 2006 @ North Texas, USA
#37
Originally Posted by lcuk View Post
thats remarkable (tho extreme, we like comments)
I agree, although with good formatting and use of descriptive variable names, code can be highly self-documenting.

And I wonder if use of in-line comments versus separate-line comments makes a difference? Greg, can you test that also?
__________________
Nokia Developer Champion
Different <> Wrong | Listen - Judgment = Progress | People + Trust = Success
My personal site: http://texrat.net
 

The Following User Says Thank You to Texrat For This Useful Post:
Posts: 1,341 | Thanked: 708 times | Joined on Feb 2010
#38
Originally Posted by dalonso View Post
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.
What is NMU?
 
Posts: 1,341 | Thanked: 708 times | Joined on Feb 2010
#39
Originally Posted by epage View Post
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.
And you loose one of the benefits of Python; readability.
I find it not a good solution to strip comments and remove empty lines for speed sacrificing readability, therefore increasing the probability of bugs and making debugging harder.
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#40
Originally Posted by zimon View Post
What is NMU?
Non-Maintainer Upload (it's a Debian thing, not Python - don't freak out ). IIRC Happens when the maintainer goes AWOL or a system change/security issue/bug report required response from the distro folks.

http://wiki.debian.org/NonMaintainer...w&redirect=NMU
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 

The Following User Says Thank You to attila77 For This Useful Post:
Reply

Tags
performance, python


 
Forum Jump


All times are GMT. The time now is 09:13.