[Python-Dev] performance delta with .py presence v.s. only pyc on python 2.7.x?

Skip Montanaro skip.montanaro at gmail.com
Tue Oct 7 20:22:35 CEST 2014

On Tue, Oct 7, 2014 at 12:46 PM, John Smith <sansprivacy at gmail.com> wrote:
> pyc-only install sees mediocre performance. (pyc's are built using
> compileall.py, then source .py's removed before packaging)

(Warning: it's been probably a decade since I looked at any of this
stuff, so treat this response as mere conjecture.)

I'd take a look at startup time and things like stat(2) calls in the
presence or absence of .py files. It's possible that it tries all
other possible file extensions before considering .pyc. If you have a
long sys.path, it would then run through all the other file extension
possibilities before trying the .pyc. OTOH, if the .py is present, it
might be found early in the search, then as an optimization, look for
a .pyc file it can use rather than compiling the .py file. How long is


More information about the Python-Dev mailing list