473,695 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python bytecode compatibility between interpreter versions

Can one run a 1.5 .pyc file with the 2.x version
interpreters and vice versa?

How about running a 2.x .pyc using a 2.y interpreter?
Jul 18 '05 #1
46 6273
>>>>> "Jon" == Jon Perez <jb********@yah oo.com> writes:

Jon> Can one run a 1.5 .pyc file with the 2.x version
Jon> interpreters and vice versa?

Nope, bytecode compatibility is not guaranteed.

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #2
Jon Perez <jb********@yah oo.com> writes:
Can one run a 1.5 .pyc file with the 2.x version
interpreters and vice versa?

How about running a 2.x .pyc using a 2.y interpreter?


Both are hopeless, in practice.

Cheers,
mwh

--
ZAPHOD: OK, so ten out of ten for style, but minus several million
for good thinking, eh?
-- The Hitch-Hikers Guide to the Galaxy, Episode 2
Jul 18 '05 #3
Jon Perez wrote:
Can one run a 1.5 .pyc file with the 2.x version
interpreters and vice versa?

How about running a 2.x .pyc using a 2.y interpreter?


What is the specific need you have? There may be ways around
your problem.

-Peter
Jul 18 '05 #4
Peter Hansen wrote:
Jon Perez wrote:
Can one run a 1.5 .pyc file with the 2.x version
interpreters and vice versa?

How about running a 2.x .pyc using a 2.y interpreter?

What is the specific need you have? There may be ways around
your problem.

-Peter


I was just curious wrt deployment issues. So I guess it is
fair to say that .pyc files are not as flexible as Java
class files which are at least forward compatible in most
cases (i.e. old class files will run on newer JVMs).

I'm sure a 2.N.x .pyc can run on a 2.N.y interpreter though,
right? :-D

The answers also make me curious about how CPython's VM works.
I suppose that, unlike Java, it is constantly being reworked
in more extensive ways from one dot-version to another. Would
that also explain why there is no detailed spec detailing how
CPython's VM works (since its design is not as nailed down as,
say, the JVM)?

As a programmer, I find installing (and uninstalling) Python
extensions to be about as easy as one can wish for. However,
for end users, it would be great if we can someday have the
equivalent of a Java Runtime Environment with all the important
extensions already included. Then Python developers can distribute
..pycs to end-users and expect them to work with few to no issues.

The things I would like to see in this hypothetical Python Runtime
Environment (PRE) would be Pygame, PyOpenGL, PyGtk (once it finally
matures on Aqua), and the other popular extensions they rely on (like
Numeric - although the current PyOpenGL is experimenting with
using numarray instead).

It may not necessarily have to be the current lightweight distro being
released by the offical Python maintainers, but a separate one
specifically geared for end users who mainly wish to use 3rd party apps
written in Python. Due to Python's nature, such a PRE would also
automatically be an effective developer environment, nullifying the
need for an SDK edition.

Jul 18 '05 #5
> I was just curious wrt deployment issues. So I guess it is
fair to say that .pyc files are not as flexible as Java
class files which are at least forward compatible in most
cases (i.e. old class files will run on newer JVMs).
It is not about Python being "less flexible" than Java, Python is
evolving. It is also stated in the docs somewhere that bytecode is not
guaranteed to be forwards or backwards compatible.

I'm sure a 2.N.x .pyc can run on a 2.N.y interpreter though,
right? :-D
Yeah, they try not to do bytecode changes mid point releases.

The answers also make me curious about how CPython's VM works.
I suppose that, unlike Java, it is constantly being reworked
in more extensive ways from one dot-version to another. Would
that also explain why there is no detailed spec detailing how
CPython's VM works (since its design is not as nailed down as,
say, the JVM)?
Virtual machine, interpreter, call it what you want. There is probably
documentation somewhere, but the best idea (if you are interested) is to
just take a dive into the source. It is all browsable on sourceforge.

As a programmer, I find installing (and uninstalling) Python
extensions to be about as easy as one can wish for. However,
for end users, it would be great if we can someday have the
equivalent of a Java Runtime Environment with all the important
extensions already included. Then Python developers can distribute
..pycs to end-users and expect them to work with few to no issues.
IMO you are better off packaging them with py2exe or an equivalent for
your platform. Then you can guarantee that your users are running
python version x.y.z, and not x.y.a (minor releases are to fix
relatively important bugs, which may effect the execution of your program).

The things I would like to see in this hypothetical Python Runtime
Environment (PRE) would be Pygame, PyOpenGL, PyGtk (once it finally
matures on Aqua), and the other popular extensions they rely on (like
Numeric - although the current PyOpenGL is experimenting with
using numarray instead).
Such a PRE would not be small, and trying to get compatible versions of
all of those 3rd party modules, for every supported platform, would be a
pain in the ass.

It may not necessarily have to be the current lightweight distro being
released by the offical Python maintainers, but a separate one
specifically geared for end users who mainly wish to use 3rd party apps
written in Python. Due to Python's nature, such a PRE would also
automatically be an effective developer environment, nullifying the
need for an SDK edition.


There already exist 3rd party Python distributions with various add-ons.
I don't know of any off the top of my head (because I have no need for
them), but I have heard mention of them here.

- Josiah
Jul 18 '05 #6
Josiah Carlson wrote:
It is not about Python being "less flexible" than Java, Python is
evolving.
Note that I specifically mentioned .pyc files vs. java class files,
not Java the language/environment/platform vs. Python.
It is also stated in the docs somewhere that bytecode is not
guaranteed to be forwards or backwards compatible.
Ah ok.
IMO you are better off packaging them with py2exe or an equivalent for
your platform. Then you can guarantee that your users are running
python version x.y.z, and not x.y.a (minor releases are to fix
relatively important bugs, which may effect the execution of your program).
Right. I am aware that freezing is the optimal way to distribute
apps written in Python today. After trying out Java though, I have
to say I'm impressed with the way you can take a bunch of class
files archived in the exact same jarfile to *ANY* computer with a
JRE installed, type in java -jar jarfile and have it run _identically_.

Perhaps one day .pyc files can work in such a manner.
Such a PRE would not be small, and trying to get compatible versions of
all of those 3rd party modules, for every supported platform, would be a
pain in the ass.
That it would not be small I will agree with you on, however I don't
believe version [in]compatibilities will become a PITA as it isn't so
even today.

The whole idea of a Python Runtime Environment came to me precisely
because I have tried out Pygame, PyOpenGL, PyGTK on both Win32 and
Linux and they work seamlessly and uniformly on both platforms (not sure
on OS X though). Note that these are modules that tie intimately with
_different_ low-level APIs on each platform but they work so flawlessly
that it reminds of me of Java's WORA which has been a reality for a
long time now. The main difference is that with Python, getting all
these different modules (for multimedia, 3d acceleration, GUI) installed
involves more steps (though quite easy). Also, because these work
on top of C-based APIs, the performance is significantly superior to
Java's.
There already exist 3rd party Python distributions with various add-ons.
I don't know of any off the top of my head (because I have no need for
them), but I have heard mention of them here.


ActiveState's and Pythonware's are the two I am aware of.
Jul 18 '05 #7
| ....
| ActiveState's and Pythonware's are the two I am aware of

There are also the Enthought distributions ....

Python 2.3 and Python 2.2.3
for Windows (Enthought Edition) ....

http://www.enthought.com/

I've been using the 2.3 version successfully
for several months and chose it specifically
because several add-on packages were included
that I didn't have to seek out and otherwise
individually install ....

--
Cousin Stanley
Human Being
Phoenix, Arizona

Jul 18 '05 #8

"Jon Perez" <jb********@yah oo.com> wrote in message
news:c3******** *****@ID-180326.news.uni-berlin.de...
The answers also make me curious about how CPython's VM works.
I suppose that, unlike Java, it is constantly being reworked
in more extensive ways from one dot-version to another. Would
that also explain why there is no detailed spec detailing how
CPython's VM works (since its design is not as nailed down as,
say, the JVM)?


The CPython VM is intentionally underdocumented and intentionally not part
of the language spec. It is still being developed and might radically
change in the future. There will probably be minor changes in the next
release as a result of experiments designed to find combinations of codes
that dependably run faster on all major platforms. However, the current
byte code is described in the Library Ref as part of the doc for the dis
(assembly) module.

Terry J. Reedy


Jul 18 '05 #9
In article <c3************ *@ID-180326.news.uni-berlin.de>,
Jon Perez <jb********@yah oo.com> wrote:

Right. I am aware that freezing is the optimal way to distribute
apps written in Python today. After trying out Java though, I have
to say I'm impressed with the way you can take a bunch of class
files archived in the exact same jarfile to *ANY* computer with a
JRE installed, type in java -jar jarfile and have it run _identically_.


Really? I'm sorry, I have just a tiny bit of difficulty believing that,
considering all the stories i've heard about Java not being completely
cross-platform and cross-version. I am sure that simple cases work as
you describe, but I'd like a cite for Java working as you describe in
general.
--
Aahz (aa**@pythoncra ft.com) <*> http://www.pythoncraft.com/

"usenet imitates usenet" --Darkhawk
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2396
by: Anon | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all I am a beginner teaching myself python, and I am enjoying it immensely :) As a language it is great, I real treat to study, I actually find it fun to study the language heh Anyways to the point of my post.....
4
2003
by: Ognjen Bezanov | last post by:
Hello All, I am a third year computer science student and I'm the process of selection for my final year project. One option that was thought up was the idea of implement my own version of the python interpreter (I'm referring to CPython here). Either as a process running on another OS or as a process running directly on the CPU. Now, I can't seem to find a decent source of information on the python
0
1587
by: Robert Kern | last post by:
Ognjen Bezanov wrote: Mostly. It is worth noting, though, that the Python bytecode is at a higher level than Java bytecode. You can run other languages on top of the JVM using Java bytecode (Python, for one), but Python bytecode is geared very much towards running Python code with Python's object model. Several years ago, there was someone who wrote up such a document for a university project. Unfortunately, my Google-fu has failed...
0
8628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8981
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7660
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6490
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5839
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3001
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.