Compiler

S

Steven

Hi folks,

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

Regards,

Steven
 
P

Peter Hansen

Steven said:
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
 
M

Maurice LING

Peter said:
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
 
R

Roger Binns

Maurice said:
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
 
T

Terry Reedy

Maurice LING said:
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
 
R

Rick L. Ratzel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top