Python 2.7 importing pyc files without py files

Terry Reedy tjreedy at udel.edu
Wed Feb 19 23:26:02 CET 2014


On 2/19/2014 5:03 PM, Mircescu Andrei wrote:
> Hi,
>
>
> I encountered a strange issue. 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 ? Maybe is because, python
> tries to search the py file in all the paths and this search is
> exhaustive ? This is the best guess I could figure it out but I'm not
> sure.

It seems plausible. Once .py is found, the .pyc is in the same directory.

> Also, if this is the scenario, there is a way I can stop this, to not
> search for the py files ?

Try reducing sys.path to the minimum needed.

-- 
Terry Jan Reedy




More information about the Python-list mailing list