[Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

Glyph Lefkowitz glyph at twistedmatrix.com
Mon Aug 31 05:13:49 CEST 2009

On Sun, Aug 30, 2009 at 8:26 PM, Guido van Rossum <guido at python.org> wrote:

> On Sun, Aug 30, 2009 at 5:23 PM, Brett Cannon<brett at python.org> wrote:
> > Right; the code object would think it was loaded from the original
> > location it was created at instead of where it actually is. Now why
> > someone would want to move their .pyc files around instead of
> > recompiling I don't know short of not wanting to send someone source.
> I already mentioned replication; it could also just be a matter of
> downloading a tarball with .py and .pyc files.

Also, if you're using Python in an embedded context, bytecode compilation
(or even filesystem access!) can be prohibitively slow, so an uncompressed
.zip file full of compiled .pyc files is really the way to go.

I did this a long time ago on an XScale machine, but recent inspection of
the Android Python scripting stuff shows a similar style of deployment (c.f.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090830/e2b7168d/attachment.htm>

More information about the Python-Dev mailing list