Compiled Byte code

Michael Hudson mwh at python.net
Thu Oct 14 16:57:45 CEST 2004


Cliff Wells <clifford.wells at comcast.net> writes:

> On Wed, 2004-10-13 at 19:19 +0530, Soumitri wrote:
> > Hi,
> > 
> > Is there a dependency of version or platform for running a snippet of
> > python compiled code? I have a .pyc (possibly created on a *nix box)
> > that was created off ver 1.5.2 and returns a "Bad Magic Number in .pyc
> > file" error when i run a box with XP and Python 2.3.
> 
> IIRC, I believe bytecode (pyc files), while mostly portable across
> platforms (I've used the same pyc files on Linux and Windows)

Uh, *entirely* portable, I hope, or you've found a bug :-).

Oh, well, you might get into trouble with things like floating point
constants that turn out to be NaNs (e.g. 1e3000).  But you'll have
trouble with those even without moving .pycs between platforms.  And
floating point numbers in general might be problematical if the libc
on the generating platform really sucks.  Err, yeah, mostly portable
:-)

> aren't portable across major versions of Python.

To be clearer, major version in this sense means that bytecode for 2.X
is not guaranteed to (and in practice, won't) run on 2.Y, but bytecode
for 2.X.Y *will* run on 2.X.Z.

Cheers,
mwh

-- 
  > Well, as an American citizen I hope that the EU tells the MPAA 
  > and RIAA to shove it where the Sun don't shine.
  Actually they already did. Only first they bent over and dropped
  their trousers.      -- Shmuel (Seymour J.) Metz & Toni Lassila, asr



More information about the Python-list mailing list