top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Python: Importing pyc files without py files takes more time?

+2 votes
589 views

I have an application which uses extensively python 2.7.6 (CPython).

The issue that I see is the following: "If there are only pyc files, the loading time of the application is much more than if I have pyc and py files. It is behind with 2 minutes more than if it had py files"

Do you have any idea why this is happening?

posted Feb 19, 2014 by Tarun Singhal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

You may get some clues by starting python as

/path/to/python/python2.7 -vv

which will provide the details of attempts to import:

$ python2.7 -vv
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# trying /usr/local/lib/python2.7/site.so
# trying /usr/local/lib/python2.7/sitemodule.so
# trying /usr/local/lib/python2.7/site.py
# /usr/local/lib/python2.7/site.pyc matches /usr/local/lib/python2.7/site.py
import site # precompiled from /usr/local/lib/python2.7/site.pyc
# trying /usr/local/lib/python2.7/os.so
# trying /usr/local/lib/python2.7/osmodule.so
# trying /usr/local/lib/python2.7/os.py
# /usr/local/lib/python2.7/os.pyc matches /usr/local/lib/python2.7/os.py
import os # precompiled from /usr/local/lib/python2.7/os.pyc
answer Feb 19, 2014 by anonymous
Similar Questions
+2 votes

http://www.python.org/workshops/1998-11/proceedings/papers/montanaro/montanaro.html

Just wanted to clarify whether CPython already includes these kind of byte code optimizations? Are all the temporary variables removed when byte code is generated?

0 votes

I'm running a box with Debian squeeze, and I just ran:

sudo aptitude install jython

which ended up installing Python 2.5:

[...]
Linking and byte-compiling packages for runtime python2.5...
Setting up python2.5 (2.5.5-11) ...

Does anyone know why CPython 2.5 is a dependency for Jython 2.5.1+ on Debian squeeze?

0 votes

I'm currently trying to make sense of Python's Timsort function. From the wikipedia page I was told the algorithm is located somewhere here: http://hg.python.org/cpython/file/default/Objects/listobject.c

So of all the functions in there, could somebody point to me which one is timsort?

+1 vote

I have installed, de-installed and reinstalled this s/w and MySQL itself on my Win8 box. However, when I go to use it from a script, I get the following error:

"C:Python27libsite-packagesMySQLdb__init.py__", line 27 in  import _mysql
ImportError: DLL load failed: %1 is not valid Win32 application. 

I'm running Win8 which is 64-bit, Python 27, MySQL 5.5. Please help?

+1 vote

I want to install path.py in my Python 3.4 environment on a Centos 5 box. My /usr/local/bin/ contains:

easy_install-3.4 
python3.4  
etc. 

We are behind a proxy server and I tried this:

# /usr/local/bin/easy_install-3.4 path.py 

Searching for path.py 
Reading https://pypi.python.org/simple/path.py/ 
Download error on https://pypi.python.org/simple/path.py/: hostname '172.29.68.1  
' doesn't match either of 'www.python.org', 'python.org', 'pypi.python.org',  
'docs.python.org', 'testpypi.python.org', 'bugs.python.org', 'wiki.python.org',  
'hg.python.org', 'mail.python.org', 'packaging.python.org', 'pythonhosted.org',  
'www.pythonhosted.org', 'test.pythonhosted.org', 'us.pycon.org', 'id.python.org' --  
Some packages may not be found! 

Couldn't find index page for 'path.py' (maybe misspelled?), Am I best to use pip or easy_install? also if easy_install, how can I fix the above error?

...