Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40938
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'python': 0.09; 'imported': 0.09; 'it;': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:number': 0.09; '2.7': 0.13; '.py': 0.16; '2.7:': 0.16; '3.2.': 0.16; '__pycache__': 0.16; 'clash': 0.16; 'occur.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.17; 'compilation': 0.17; 'module': 0.19; 'import': 0.21; '3.2': 0.22; 'subject:problem': 0.22; 'runs': 0.22; 'header:User-Agent:1': 0.26; 'compiled': 0.27; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'cat': 0.29; 'python2.7': 0.29; 'unlikely': 0.29; 'probably': 0.29; "i'm": 0.29; 'version,': 0.30; 'file': 0.32; '(2)': 0.32; 'skip:_ 30': 0.32; 'problem': 0.33; 'to:addr:python- list': 0.33; 'code:': 0.33; '(1)': 0.34; 'offered': 0.35; 'received:org': 0.36; 'created': 0.36; 'but': 0.36; 'correctly': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'world': 0.63; 'more': 0.63; 'due': 0.66; 'subject: ': 0.66; 'execution.': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Apparent magic number problem |
| Date | Sat, 09 Mar 2013 09:51:31 +0100 |
| Organization | None |
| References | <khe0st$k45$1@theodyn.ncf.ca> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084a829.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3120.1362819075.2939.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362819075 news.xs4all.nl 6964 [2001:888:2000:d::a6]:51623 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40938 |
Show key headers only | View raw
Colin J. Williams wrote:
> The program runs correctly under each version, but it runs more slowly
> under 3.2.
> This is probably due to the fact that the .pyc file is created for the
> Python 2.7 execution.
> When Python 3.2 is run it fails to create a new .pyc file and if the 2.7
> .pyc is offered directly a magic number problem is reported.
(1) .pyc files are only created if a module is imported
(2) The 2.7 .pyc file is put alongside the .py file whereas the 3.2 .pyc is
put into the __pycache__ subfolder. No clash can occur.
A simple example:
$ ls
mod.py
$ cat mod.py
print("hello world")
Run it; no pyc is created:
$ python2.7 mod.py
hello world
$ ls
mod.py
Import it using 2.7:
$ python2.7 -c 'import mod'
hello world
$ ls
mod.py mod.pyc
Import it using 3.2:
$ python3.2 -c 'import mod'
hello world
$ ls
mod.py mod.pyc __pycache__
$ ls __pycache__/
mod.cpython-32.pyc
Run the compiled code:
$ python2.7 mod.pyc
hello world
$ python3.2 __pycache__/mod.cpython-32.pyc
hello world
But I'm with Steven, it's unlikely that the module compilation phase is
responsible for a noticeable slowdown.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Apparent magic number problem "Colin J. Williams" <cjw@ncf.ca> - 2013-03-08 19:48 -0500
Re: Apparent magic number problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-09 05:22 +0000
Re: Apparent magic number problem Peter Otten <__peter__@web.de> - 2013-03-09 09:51 +0100
Re: Apparent magic number problem "Colin J. Williams" <cjw@ncf.ca> - 2013-03-09 10:16 -0500
Re: Apparent magic number problem Peter Otten <__peter__@web.de> - 2013-03-10 11:56 +0100
csiph-web