[Distutils] .py vs .pyc (was: Newbie questions about setuptools)

Zooko O'Whielacronx zooko at zooko.com
Mon Jul 16 22:07:58 CEST 2007


On Jul 7, 2007, at 11:04 AM, Phillip J. Eby wrote:

> At 10:12 AM 7/7/2007 -0600, Zooko O'Whielacronx wrote:
>>
>> I would prefer to ship compiled C modules and source .py files.
...
>> So, please accept this as a feature request to make the above-
>> mentioned behavior configurable for users such as me.
>
> For the reasons I already explained above, this is a no-go.  If you  
> want to ship binaries plus source, ship eggs.  If you want to ship  
> without .pyc/.pyo files, ship an sdist.
>
> This distinction is not about your preferences as a distributor,  
> but about your users.  As a user, I don't want to pay for .py- 
> compilation every time I import your modules, just to save you a  
> few extra bytes of bandwidth.
>
> If the option existed to ship without compiled modules, people  
> would use it.  Following which, other people would begin claiming  
> that "eggs are slow".  And all this, for what actual benefit?   
> Absolutely zip!  ...no pun intended.

My motivations are to benefit my users, not to reduce my bandwidth  
usage (which is negligible).  Perhaps some users have different  
values than others with respect to download time versus launch time.

Have you measured the relative launch time for .py's vs. .pyc's?  I  
certainly wouldn't want to impose an excessive increase in launch  
time, but if it is sufficiently small then I may choose to ship  
just-.py instead of just-.pyc or both-.py-and-.pyc.

Let's see...

Hm.  After experimenting with a bit here, it seems to take just as  
long to launch with .pyc's-and-.py's as with .py's alone, but it  
seems to be faster with .pyo's-and-.py's.  However, I don't trust  
these results -- I only ran each test once, and this machine isn't idle.

So it remains an open question in my mind as to how much, if  
any, .pyc's accelerates launch time.  Perhaps I'll do some better  
benchmarking next time I find myself packaging up a release of my  
major project (http://allmydata.org ).  If anyone else has measured  
this behavior more carefully I'd like to hear about it.  Just to  
reiterate, I value making source code easily available to users, so I  
would prefer to ship .py files unless it is too costly.  (And I would  
prefer not to ship .pyc or .pyo files unless they help with launch  
time more than they hurt with download time.)

Regards,

Zooko



More information about the Distutils-SIG mailing list