编译为python字节码 [英] compiling to python byte codes

查看:82
本文介绍了编译为python字节码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我记得读过关于将Perl编译为Java字节码的MSc论文

(如java类文件中所示)。至少,似乎有人已经成功地编译了java类文件的
方案。我想知道是否在python中尝试了一些这样的东西,就像在.pyc中编译X

语言一样。我不明白.pyc文件的原理图但是

我认为它们是所谓的python字节码文件。


或者是否有任何文档或书籍这就是python等价于

Java虚拟机编程约书亚恩格尔?


谢谢

莫里斯

-

莫里斯韩彤玲,BSc (荣誉)(MCB),AdvDipComp,SSN,FIFA

墨尔本大学哲学博士(科学)候选人

手机:+61 4 22781753

+65 96669233

邮寄地址:墨尔本大学动物学系

Royal Parade,Parkville,Victoria 3010,Australia

住址:9/41 Dover Street

Flemington,Victoria 3031,Australia

email: ma ********* @ acm.org

简历: http://maurice.vodien.com/maurice_resume.pdf

www: http://www.geocities.com/beldin79/


信息包含在此消息中,包括其附件,

是CONFIDEN TIAL仅适用于其收件人。此邮件的

内容(包括其附件)可能会受到版权和隐私法的约束。如果您错误地收到了这封电子邮件,请回复此电子邮件告知我们,然后销毁所有副本。


我找不到任何人我知道肯定说什么是

和什么是不可能的 -Henry Ford

不可能和可能的谎言之间的差异

在一个人的决心中 -Tommy Charles Lasorda

Hi,

I remembered reading a MSc thesis about compiling Perl to Java bytecodes
(as in java class files). At least, it seems that someone had compiled
scheme to java class files quite successfully. I''m wondering if
something of such had been attempted in python, as in compiling X
language into .pyc. I do not understand the schematics of .pyc files but
I assume that they are the so called python bytecode files.

Or is there any documentation or books that is the python equivalent of
"Programming for the Java Virtual Machine" by Joshua Engel?

Thanks
Maurice
--
Maurice Han Tong LING, BSc(Hons)(MCB), AdvDipComp, SSN, FIFA
Doctor of Philosophy (Science) Candidate, The University of Melbourne
mobile: +61 4 22781753
+65 96669233
mailing address: Department of Zoology, The University of Melbourne
Royal Parade, Parkville, Victoria 3010, Australia
residential address: 9/41 Dover Street
Flemington, Victoria 3031, Australia
email: ma*********@acm.org
resume: http://maurice.vodien.com/maurice_resume.pdf
www: http://www.geocities.com/beldin79/

The information contained in this message, including its attachment(s),
is CONFIDENTIAL and solely intended to its addressee(s) only. The
content of this message, including its attachment(s), may be subjected
to copyright and privacy laws. If you have received this email in error,
please let me know by returning this email, and then destroy all copies.

"I cannot discover anyone knows enough to say definitely what is
and what is not possible" -Henry Ford
"The difference between the impossible and the possible lies
in a person''s determination" -Tommy Charles Lasorda

推荐答案

Maurice LING写道:
Maurice LING wrote:
我记得读过关于将Perl编译为Java字节码的MSc论文
(如在java类文件中)。


你不必看那么远。 Jython将Python代码编译成Java

字节码; IronPython将Python代码编译成Microsoft中级

语言。

我想知道是否在python中尝试过这样的东西,比如编译X
语言到.pyc。


创建.pyc文件的最简单方法是创建一个Python文件,然后编译它。有各种工具可以将X编译为

..pyc。例如,Fnorb将OMG IDL编译成.pyc文件。

我不明白.pyc文件的原理图但是我认为它们是所谓的python字节码文件。


这是正确的。

或者是否有任何文档或书籍相当于
Java虚拟程序设计机"作者:Joshua Engel?
I remembered reading a MSc thesis about compiling Perl to Java bytecodes
(as in java class files).
You don''t have to look that far. Jython compiles Python code into Java
bytecode; IronPython compiles Python code into Microsoft intermediate
language.
I''m wondering if
something of such had been attempted in python, as in compiling X
language into .pyc.
The easiest way to create a .pyc file is to create a Python file,
and then compile that. There are various tools that compile X to
..pyc. For example, Fnorb compiles OMG IDL into .pyc files.
I do not understand the schematics of .pyc files but
I assume that they are the so called python bytecode files.
That''s correct.
Or is there any documentation or books that is the python equivalent of
"Programming for the Java Virtual Machine" by Joshua Engel?




有dis模块及其文档。但是,正如我所说,在
Python中,你并不需要*直接创建.pyc文件,因为Python编译器总是可以通过compile()内置

函数。这与Java或.NET不同,JRE或.NET商业框架中的编译器不是



问候,
Martin



There is the dis module and its documentation. However, as I said, in
Python, you don''t really *need* to create .pyc files directly, as
the Python compiler is always available through the compile() builtin
function. This is unlike Java or .NET, where the compiler is not
available in the JRE, or the .NET commercial framework.

Regards,
Martin


Maurice LING写道:
Maurice LING wrote:
或者是否有任何文档或书籍相当于
用于Java虚拟机的编程。作者:Joshua Engel?
Or is there any documentation or books that is the python equivalent of
"Programming for the Java Virtual Machine" by Joshua Engel?




Python的字节码不是很稳定,所以你可能需要重新创建你的

整个代码基于每个新的Python版本。我建议改为生成Python代码(不是字节代码)并编译它。



Python''s byte code isn''t very stable, so you might have to recreate your
entire code base with every new Python version. I would suggest
generating Python code (not byte code) instead and compiling that.


" Martin v.L?wis" <毫安**** @ v.loewis.de>在留言新闻中写道:< 41 ********************* @ news.freenet.de> ...
"Martin v. L?wis" <ma****@v.loewis.de> wrote in message news:<41*********************@news.freenet.de>...
Maurice LING写道:
Maurice LING wrote:
我记得读过关于将Perl编译为Java字节码的MSc论文(如在java类文件中)。
I remembered reading a MSc thesis about compiling Perl to Java bytecodes
(as in java class files).



你不是必须看那么远。 Jython将Python代码编译成Java
字节码; IronPython将Python代码编译成微软的中间语言。



You don''t have to look that far. Jython compiles Python code into Java
bytecode; IronPython compiles Python code into Microsoft intermediate
language.

我想知道是否在python中尝试过这样的东西,比如编译X
language into .pyc。
I''m wondering if
something of such had been attempted in python, as in compiling X
language into .pyc.



创建.pyc文件的最简单方法是创建一个Python文件,然后编译它。有各种工具可以将X编译为
.pyc。例如,Fnorb将OMG IDL编译成.pyc文件。



The easiest way to create a .pyc file is to create a Python file,
and then compile that. There are various tools that compile X to
.pyc. For example, Fnorb compiles OMG IDL into .pyc files.

我不了解.pyc文件的原理图但是我认为它们是所谓的python字节码文件。
I do not understand the schematics of .pyc files but
I assume that they are the so called python bytecode files.



这是正确的。



That''s correct.

或者是否有任何类似于
的文档或书籍。 Java虚拟机的编程作者:Joshua Engel?
Or is there any documentation or books that is the python equivalent of
"Programming for the Java Virtual Machine" by Joshua Engel?



有dis模块及其文档。但是,正如我所说,在Python中,你并不需要*直接创建.pyc文件,因为Python编译器始终可以通过compile()内置来获得
功能。这与Java或.NET不同,后者在JRE或.NET商业框架中无法使用编译器。

问候,
Martin



There is the dis module and its documentation. However, as I said, in
Python, you don''t really *need* to create .pyc files directly, as
the Python compiler is always available through the compile() builtin
function. This is unlike Java or .NET, where the compiler is not
available in the JRE, or the .NET commercial framework.

Regards,
Martin



但是这仍然没有回答OP问题,即用另一种语言编写
代码来生成python字节码....


哪个很有意思......但我觉得并不是那么有趣。

python字节码*是否与Java字节码不同(不详细说明

但在概念上?) 。有没有理由为什么另一个编译器不能
发出python字节码来运行''python虚拟机''? (很多

的理由不这样做我想没有理由为什么它不应该是

可能)。


问候,


模糊

http://www.voidspace.org.uk/atlantib...thonutils.html


这篇关于编译为python字节码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆