redundant importr

Peter Hansen peter at engcorp.com
Mon Apr 4 10:06:46 EDT 2005


max(01)* wrote:
> Peter Hansen wrote:
>> No it doesn't.  I thought I was clear, but I can reword
>> it for you: the files are compiled *in-memory* and the
>> results are never written to disk.
>>
>>  > *if* they are compiled, where are they put, if the
>>> corresponding *.py files are on a non-writeable directory?
>>
>> They are not put anywhere.  
> 
> ok, maybe it is an implementation-dependent issue after all.

Not really.

> consider this:
[snip]
> -rw-r--r--    1 max2     max2          307 2005-04-02 17:45 imported.pyc
> 
> see?

Yes, but you don't, yet. :-)

Obviously the .pyc file is being written, so my comments
above, out of context, is wrong.

Now please go put them back in context.  You asked what
would happen if the directory was not writable.  That's
the context in which to interpret my claims that the
bytecode (the *result* of the compilation) is not
written to disk.

I'll try one last time, before giving up in abject
failure and letting someone else take a stab at this:
the compilation will occur every time if a .pyc file
does not exist.  The interpreter will attempt to write
the results of the compilation process to disk in a
.pyc file to cache it for the next time, to avoid
having to recompile.  *If* this is not possible, then
no caching takes place, no .pyc file is written, and
the next time you run the code, the compilation step
will occur all over again (note: with the results being
held in memory only while the program runs, then
discarded).

Please tell me it's clear now. :-)

-Peter



More information about the Python-list mailing list