On Fri, Feb 26, 2010 at 15:35, Glenn Linderman <v+python@g.nevcal.com> wrote:
On approximately 2/26/2010 2:55 PM, came the following characters from the keyboard of Brett Cannon:


   Maybe Greg's and my response to the mention of dropping this feature
   is too strong -- after all we're both dinosaurs. And maybe the
   developers who want the feature can write their own loader.


We could also provide if necessary.

So if the implementation stores .pyc by default in a version-specific place, then it seems there are only two things needed to make a python byte-code only distribution...

1) rename all the .pyc to .py
2) packaging

When a .pyc is renamed to .py, Python (3.1 at least) recognizes and uses it... I assume by design, rather than accident, but I don't know the history.

This does not work for me (nor should it):

> touch temp.py                                                               
> python3 -c "import temp"                                                      
> rm temp.py                                                                    
> mv temp.pyc temp.py                                                           
> python3 -c "import temp"                                                      
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "temp.py", line 2
SyntaxError: Non-UTF-8 code starting with '\x95' in file temp.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

-Brett


 

I didn't experiment to discover what __file__ and __cached__ get set to in this case (especially since I don't have a version with the latter :) ).

I speculate that packaging a distribution in this manner would be slightly different that how it is currently done, but I also suspect that it would avoid the same half of the stat calls, to aid performance.

--
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking