Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66720 > unrolled thread
| Started by | Mircescu Andrei <mircescu.andrei@gmail.com> |
|---|---|
| First post | 2014-02-19 14:03 -0800 |
| Last post | 2014-02-19 17:26 -0500 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
Python 2.7 importing pyc files without py files Mircescu Andrei <mircescu.andrei@gmail.com> - 2014-02-19 14:03 -0800
Re: Python 2.7 importing pyc files without py files Emile van Sebille <emile@fenx.com> - 2014-02-19 14:25 -0800
Re: Python 2.7 importing pyc files without py files Mircescu Andrei <mircescu.andrei@gmail.com> - 2014-02-20 05:36 -0800
Re: Python 2.7 importing pyc files without py files Terry Reedy <tjreedy@udel.edu> - 2014-02-19 17:26 -0500
| From | Mircescu Andrei <mircescu.andrei@gmail.com> |
|---|---|
| Date | 2014-02-19 14:03 -0800 |
| Subject | Python 2.7 importing pyc files without py files |
| Message-ID | <8a6aff2d-777a-4f80-8c26-6d1a586e6c5c@googlegroups.com> |
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. Also, if this is the scenario, there is a way I can stop this, to not search for the py files ? is there an api ? or a compiling flag I should set ?
[toc] | [next] | [standalone]
| From | Emile van Sebille <emile@fenx.com> |
|---|---|
| Date | 2014-02-19 14:25 -0800 |
| Message-ID | <mailman.7166.1392848757.18130.python-list@python.org> |
| In reply to | #66720 |
On 2/19/2014 2:03 PM, Mircescu Andrei wrote: > 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 You may get some clues by starting python as /path/to/python/python2.7 -vv which will provide the details of attempts to import: [root@vsds4 log]# 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 ... HTH, Emile
[toc] | [prev] | [next] | [standalone]
| From | Mircescu Andrei <mircescu.andrei@gmail.com> |
|---|---|
| Date | 2014-02-20 05:36 -0800 |
| Message-ID | <8719779c-6ba4-4e72-8bcb-8c5af2864a51@googlegroups.com> |
| In reply to | #66722 |
joi, 20 februarie 2014, 00:25:41 UTC+2, Emile van Sebille a scris: > On 2/19/2014 2:03 PM, Mircescu Andrei wrote: > > > > > 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 > > > > You may get some clues by starting python as > > > > /path/to/python/python2.7 -vv > > > > which will provide the details of attempts to import: > > > > [root@vsds4 log]# 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 > > ... > > > > > > > > HTH, > > > > Emile I cannot start python since i'm embedding it in .net with pythonnet solution.
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-02-19 17:26 -0500 |
| Message-ID | <mailman.7167.1392848807.18130.python-list@python.org> |
| In reply to | #66720 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web