Re: [Tutor] Virtual Machine Terminology

Magnus Lycka magnus at thinkware.se
Thu Apr 22 08:58:32 EDT 2004


Alan Gauld wrote:
> > doesn't always look the same. You can't expect .pyc-files made under
> one
> > computer architecture to work on another computer architecture, it
> will
> > for instance look different on a 64 bit machine and on a 32 bit
> machine.
> 
> Is this true? I though pyc files were portable between architectures.
> For example I can take pyc files from my windows box and run them on
> my Sun box. (Admittedly they are both still 32 bit but I thought even
> that should be transparent)

Now that you question it, I'm not sure. On the other hand, the byte code 
is not guaranteed to be the same between Python versions, which is probably 
a worse problem. 

You might well be right, since I probably heard about this when I used Python 
version 1.4.2 or something like that... I put some integers in a list 
and looked at the corresponding byte code, and for numbers like 1, 2, 258, 
... the byte code showed 105 1 0 0 0 105 2 0 0 0 105 2 1 0 0 105 ... which 
is consistent with what I expected for a 32 bit little endian, but when the 
numbers got bigger, such as 16777217 (256**3+1) I was expecting to see 
105 1 0 0 1 105, but instead I saw 105 2 0 0 0 78 40 1 0 0 0 115, so it 
seems Python changes the way it stores integers as they grow bigger.

I tried to look at the modules in the standard Python compiler package,
to understand how this is handled, but this is far over my head... I'd
need someone to lead me gently through that code to understand how it
works.

-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus at thinkware.se




More information about the Tutor mailing list