<br><br><div class="gmail_quote">On Fri, Feb 26, 2010 at 20:08, Glenn Linderman <span dir="ltr">&lt;<a href="mailto:v%2Bpython@g.nevcal.com">v+python@g.nevcal.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

On approximately 2/26/2010 5:13 PM, came the following characters from the keyboard of Brett Cannon:<div><div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, Feb 26, 2010 at 15:35, Glenn Linderman &lt;<a href="mailto:v%2Bpython@g.nevcal.com" target="_blank">v+python@g.nevcal.com</a> &lt;mailto:<a href="mailto:v%252Bpython@g.nevcal.com" target="_blank">v%2Bpython@g.nevcal.com</a>&gt;&gt; wrote:<br>


<br>
    On approximately 2/26/2010 2:55 PM, came the following characters<br>
    from the keyboard of Brett Cannon:<br>
<br>
<br>
           Maybe Greg&#39;s and my response to the mention of dropping<br>
        this feature<br>
           is too strong -- after all we&#39;re both dinosaurs. And maybe the<br>
           developers who want the feature can write their own loader.<br>
<br>
<br>
        We could also provide if necessary.<br>
<br>
<br>
    So if the implementation stores .pyc by default in a<br>
    version-specific place, then it seems there are only two things<br>
    needed to make a python byte-code only distribution...<br>
<br>
    1) rename all the .pyc to .py<br>
    2) packaging<br>
<br>
    When a .pyc is renamed to .py, Python (3.1 at least) recognizes<br>
    and uses it... I assume by design, rather than accident, but I<br>
    don&#39;t know the history.<br>
<br>
<br>
This does not work for me (nor should it):<br>
<br>
&gt; touch temp.py<br>
&gt; python3 -c &quot;import temp&quot;<br>
&gt; rm temp.py<br>
&gt; mv temp.pyc temp.py<br>
&gt; python3 -c &quot;import temp&quot;<br>
Traceback (most recent call last):<br>
  File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;<br>
  File &quot;temp.py&quot;, line 2<br>
SyntaxError: Non-UTF-8 code starting with &#39;\x95&#39; in file temp.py on line 2, but no encoding declared; see <a href="http://python.org/dev/peps/pep-0263/" target="_blank">http://python.org/dev/peps/pep-0263/</a> for details<br>


<br>
-Brett<br>
</blockquote>
<br></div></div>
I&#39;ll admit to not doing exhaustive testing, but I&#39;ll not admit to not doing any testing... because it was sort of a wild idea.  Someone else called it &quot;kooky&quot;, which is fair.<br>
<br>
What I did was:<br>
<br>
python -m test<br>
ren test.pyc foo.py<br>
foo.py<br>
<br>
and it worked.  Then I posted, knowing that I&#39;d also tested, the other day, several .py into a .zip named .py, and once that worked, then I changed to putting all .pyc into the .zip named .py and that worked too... including imports of the several modules from the &quot;__main__.pyc&quot;.  Of course, all those were still named .pyc inside the .zip named .py.<br>


<br>
So I&#39;m not sure what the difference is...  .pyc as .py works from the command line, but not from import?  Some specialty because of using -c ?<br>
<br>
I&#39;d guess the technique could be made to work, probably not require extensive changes, if Python developers wanted to make it work.  I think it could be efficient and that same someone that called it &quot;kooky&quot; admitted it would solve their use case, at least.<br>


<br>
I&#39;m not sure why what you did is different than what I did,</blockquote><div><br></div><div>-M uses runpy which is not directly equivalent to importing.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

 nor why you state without justification that it shouldn&#39;t work...</blockquote><div><br></div><div>It just is not supposed to happen that way. Masquerading a bytecode file as a source file shouldn&#39;t work; imp.get_suffixes() controls how files should be interpreted based on their file extension.</div>

<div><br></div><div>-Brett</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> I might be able to figure out the former if I spend enough time with the documentation, if it is documented, but I&#39;m too new to Python to understand the latter without explanation.  Could you supply at least the latter explanation?  I&#39;d like to understand the issue here, whether or not the &quot;kooky&quot; idea goes forward.<div>

<div></div><div class="h5"><br>
<br>
-- <br>
Glenn -- <a href="http://nevcal.com/" target="_blank">http://nevcal.com/</a><br>
===========================<br>
A protocol is complete when there is nothing left to remove.<br>
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking<br>
<br>
</div></div></blockquote></div><br>