Error with co_filename when loading modules from zip file

Peter Otten __peter__ at web.de
Tue Mar 6 08:59:48 EST 2012


Bob Rossi wrote:

> On Tue, Mar 06, 2012 at 02:38:50AM -0800, Vinay Sajip wrote:
>> On Mar 6, 2:40 am, Bob Rossi <b... at brasko.net> wrote:
>> 
>> > Darn it, this was reported in 2007
>> > http://bugs.python.org/issue1180193
>> > and it was mentioned the logging package was effected.
>> >
>> > Yikes.
>> >
>> 
>> I will think about this, but don't expect any quick resolution :-( I
>> think the right fix would be not in the logging package, but in the
>> module loading machinery (as mentioned on that issue).
>> 
>> I wouldn't worry about the performance aspect - once the logging
>> package is loaded, there's no performance impact. That's a tiny one-
>> off hit which you will probably not notice at all.
> 
> OK.
> 
> Do you know where the bytecode gets stored when you load a py
> file from a zip?
> 
> My program can potentially run for hours, from an embedded context,
> and could call into the logger and other py files over and over.
> 
> Are the bytecode files stored in RAM one time, or recomputed each
> time they are needed?

The bytecode is generated once when the module is loaded and kept as part of 
the module object in the sys.modules cache unless you explicitly reload() 
the module. For a long-running program the compilation overhead is 
negligable.




More information about the Python-list mailing list