By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,101 Members | 2,402 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,101 IT Pros & Developers. It's quick & easy.

Compiler

P: n/a
Hi folks,

Just curious, is there a python compiler?
Or something that creates bytecode, like java?

Regards,

Steven
Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Steven wrote:
Just curious, is there a python compiler?
Or something that creates bytecode, like java?


Yes. They are the same thing. Javac compiles Java source
to Java bytecode. C compilers compile C source to
machine-specific bytecode (called machine code). Python
compiles Python source to Python bytecode. The main
difference is that Python does this transparently behind
your back whenever the source has change, while many other
languages that do it require a separate manual step...

-Peter
Jul 18 '05 #2

P: n/a
Peter Hansen wrote:
Steven wrote:
Just curious, is there a python compiler?
Or something that creates bytecode, like java?

Yes. They are the same thing. Javac compiles Java source
to Java bytecode. C compilers compile C source to
machine-specific bytecode (called machine code). Python
compiles Python source to Python bytecode. The main
difference is that Python does this transparently behind
your back whenever the source has change, while many other
languages that do it require a separate manual step...

-Peter


hi,

i was wondering just how different is the python bytecode from the java
bytecode? is there a specification for python virtual machine or sort? i
can foresee a lot of interesting projects and uses that can stem from
this specification.

maurice
Jul 18 '05 #3

P: n/a

"Maurice LING" <ma*********@acm.org> wrote in message
news:40********@news.unimelb.edu.au...
i was wondering just how different is the python bytecode from the java
For Jython, 'python bytecode' is jave bytecode.

bytecode? is there a specification for python virtual machine or sort?


For CPython, see the documentation for the CPython-specific dis (assembly)
module. Note that the details are x.y version specific, subject to change,
and not part of the language specification. For 'interesting projects'
that have been posted, try googling for Python bytecode hacks.

Terry J. Reedy


Jul 18 '05 #4

P: n/a

You can do this:

python -c "import py_compile; py_compile.compile( \"foo.py\", \"foo.pyc\" )"

...which will create foo.pyc *only*, and will not compile any other
..py files imported by foo.py.

Steven wrote:
Hi folks,

Just curious, is there a python compiler?
Or something that creates bytecode, like java?

Regards,

Steven


Jul 18 '05 #5

P: n/a
Maurice LING wrote:
i was wondering just how different is the python bytecode from the java
bytecode? is there a specification for python virtual machine or sort? i
can foresee a lot of interesting projects and uses that can stem from
this specification.


I recommend reading all the posts in this earlier thread:

http://groups.google.com/groups?th=f20ad34ef1157bcb

It largely overlaps with what you are thinking and what your next
questions would be :-)

Roger
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.