Is anyone working on a python-to-native compiler?
I'd be interested in taking a look.
Come to think of it, is anyone working on a sexpr-enabled version of
Python, or anything similar? I really miss my macros whenever I try to
use it...
Jul 18 '05
58 4027
On 2004-05-18, Svein Ove Aas <sv************ @brage.info> wrote: Seems to me that you want 'smarter', not 'worse'. I can't take a language seriously if it says that 1/3 is 0.33333... .
Dude, didn't you take high-school math? 1/3 _is_ 0.33333...
--
Grant Edwards grante Yow! My forehead feels
at like a PACKAGE of moist
visi.com CRANBERRIES in a remote
FRENCH OUTPOST!!
Brian Quinlan wrote: Svein Ove Aas wrote: Erk. Seems to me that you want 'smarter', not 'worse'. I can't take a language seriously if it says that 1/3 is 0.33333... .
What is that? Are you arguing for an integer result, a fixed result or a rational result?
A rational result, of course. If I'm okay with losing precision, I'll
*tell* the language I'm okay with losing precision.
Am Dienstag, 18. Mai 2004 13:41 schrieb Jacek Generowicz: Native compilers for other languages just as dynamic as Python exist. These compilers manage to achieve very significant speed increases[*].
You are again refering to LISP as an example of a dynamic language which when
compiled gives huge speed increases. This is true in some respect, in others
it isn't. LISP has the advantage that type-inference may be used throughout
the program to create one version of each function, which can then be
compiled. Of course it still has to call into runtime functions to do the
high-level work, but there is actually only one representation of each
finished LISP program, and only one set and one proper order of
runtime-functions to call.
In Python this isn't true. Python, instead of LISP, is "completely " dynamic,
meaning that it's pretty impossible to do type-inference for each function
that is called (even checking types isn't possible). E.g. how do you expect
type-inference to work with the pickle module? string -> something/Error
would be the best description what pickle does. For the function which calls
pickle, do you want to create versions for each possible output of Pickle?
Which outputs of Pickle are possible? (depends on the loaded modules, which
can be loaded at runtime) There is no (sane) way to create machine-code which
calls into the appropriate (low-level) Python-runtime functions (such as
Py_List*, Py_Dict*, etc.) for such a method, at least not at compile-time.
At runtime, this is possible. See what psyco does. There's a nice presentation
on the psyco-website which explains what it does, and I guess you'll
understand when you see that why writing a "compiler" for Python is pretty
impossible.
Heiko.
Grant Edwards <gr****@visi.co m> writes: Dude, didn't you take high-school math? 1/3 _is_ 0.33333...
No, because at some point you will stop writing 3's, either out of
boredom, exhaustion or because you need to pee. At that instant, you
introduce a rounding error, making 3 * 1/3 = 0.99999999999.. . instead
of 1.0
Leif K-Brooks wrote: Svein Ove Aas wrote: Is anyone working on a python-to-native compiler? I'd be interested in taking a look.
What are you trying to achieve?
If it's faster code execution, the primary slowdown with a very high-level language like Python is caused by high-level data structures (introspection, everything being an object, etc.), not the code itself. A native compiler would still have to use high-level data structures to work with all Python code, so the speed increase wouldn't be very much.
Yes, fast execution. I have been using C. In my applications there is
a population of "chromosome s" which are arrays of floats, about 2 to 5 k
in length. Then there are subroutines which operate on a chromosome
using pointers. For example, the "crossover" routine uses two pointers
to swap portions of two chromosomes. My software sometimes runs for
hours, perform many millions of operations like these. Clearly, speed
of execution is of dramatic importance.
A related problem is that it seems to be a big deal to call C routines
from Python. I have not actually tried it, because when I read about
how its done I was not able to understand it.
Mitchell Timin
--
"Many are stubborn in pursuit of the path they have chosen, few in
pursuit of the goal." - Friedrich Nietzsche http://annevolve.sourceforge.net is what I'm into nowadays.
Humans may write to me at this address: zenguy at shaw dot ca
Heiko Wundram wrote: Am Dienstag, 18. Mai 2004 13:41 schrieb Jacek Generowicz: Native compilers for other languages just as dynamic as Python exist. These compilers manage to achieve very significant speed increases[*].
You are again refering to LISP as an example of a dynamic language which when compiled gives huge speed increases. This is true in some respect, in others it isn't. LISP has the advantage that type-inference may be used throughout the program to create one version of each function, which can then be compiled. Of course it still has to call into runtime functions to do the high-level work, but there is actually only one representation of each finished LISP program, and only one set and one proper order of runtime-functions to call.
In Python this isn't true. Python, instead of LISP, is "completely " dynamic, meaning that it's pretty impossible to do type-inference for each function that is called (even checking types isn't possible). E.g. how do you expect type-inference to work with the pickle module? string -> something/Error would be the best description what pickle does. For the function which calls pickle, do you want to create versions for each possible output of Pickle? Which outputs of Pickle are possible? (depends on the loaded modules, which can be loaded at runtime) There is no (sane) way to create machine-code which calls into the appropriate (low-level) Python-runtime functions (such as Py_List*, Py_Dict*, etc.) for such a method, at least not at compile-time.
I suppose that's true; pickle is an exception, and the compiler would pick
that up. (The Lisp (print) function is approximately equivalent, at least
when *print-readably* is true.)
What you're claiming, though, is that it's possible to write Python code
that can't easily be translated to equivalent Lisp code. Can you give an
example?
* Tor Iver Wilhelmsen (2004-05-18 17:26 +0100) Grant Edwards <gr****@visi.co m> writes:
Dude, didn't you take high-school math? 1/3 _is_ 0.33333...
No, because at some point you will stop writing 3's, either out of boredom, exhaustion or because you need to pee. At that instant, you introduce a rounding error, making 3 * 1/3 = 0.99999999999.. . instead of 1.0
Must have been a long time since you went to school... 1/3 is
/exactly/ 0.3...: http://mathworld.wolfram.com/RepeatingDecimal.html
Thorsten
Heiko Wundram wrote: [...]
In Python this isn't true. Python, instead of LISP, is "completely " dynamic, meaning that it's pretty impossible to do type-inference for each function that is called (even checking types isn't possible). E.g. how do you expect type-inference to work with the pickle module? string -> something/Error would be the best description what pickle does. For the function which calls pickle, do you want to create versions for each possible output of Pickle? Which outputs of Pickle are possible? (depends on the loaded modules, which can be loaded at runtime) There is no (sane) way to create machine-code which calls into the appropriate (low-level) Python-runtime functions (such as Py_List*, Py_Dict*, etc.) for such a method, at least not at compile-time.
At runtime, this is possible. See what psyco does. There's a nice presentation on the psyco-website which explains what it does, and I guess you'll understand when you see that why writing a "compiler" for Python is pretty impossible.
That is here where you are wrong !
It can be known at compile time if you know every modules that will be
imported. That is called "closed environment".
If it is the case, you would be able to compile a program even if you
would not be allowed to do incremental compilation... That just mean
that you will need to recompile everything each time you modified something.
The demonstration is quite easy:
In a "closed environment" there is a finite number of classes. So you
just have to create as much specialized functions as classes. Then where
you can infere type, call directly the good function. Elsewhere, just
call a runtime dispatcher. In fact, it is already used in some languages
like Eiffel with certain optimizations.
The problem is that many python programs are not "closed" at
compile-time, ie they import or eval stuff only known at run-time.
impossible n'est pas français ;-)
--
Yermat
Leif K-Brooks <eu*****@ecritt ers.biz> wrote: Is anyone working on a python-to-native compiler? I'd be interested in taking a look.
If it's faster code execution, the primary slowdown with a very high-level language like Python is caused by high-level data structures (introspection, everything being an object, etc.), not the code itself. A native compiler would still have to use high-level data structures to work with all Python code, so the speed increase wouldn't be very much.
I think the main slowdown most people would see is the startup time -
the interpreter takes way too long to start (why the company where I
work won't replace Perl/PHP with Python).
If it's ease of distribution you're looking for, I think distutils can make standalone programs on Windows, and most Linux distros have Python installed by default.
Oh that one is funny - do most distro's have PyQT and wxPython (and
their supporting Qt/GKT libs) installed by default, oh and which ones
come with 2.3 by default?
If you just think a compiler would be cool (or would like to see how it would be done), check out Psyco, Pyrex, and probably some other projects. Pyrex even combats the speed issue by allowing native C types to be used in addition to Python high-level types.
I thought Pyrex was a hybrid of C and Python (like Jython/Java) not
actually a Python-to-C convertor? And Pysco is just a different VM
isn't it?
I could really push Python where I work if there was a native
compiler, my company uses C/C++/Java/Qt and were looking at QSA as a
way to allow the user to script things, but as all of our products
integrate with our software protection system, we can't be
distributing source or easily decompiled bytecode!
We could replace the whole lot with PyQt and use an embedded Python
interpreter for the scripting! Ah the frustration :-(
simo a écrit :
[...] I thought Pyrex was a hybrid of C and Python (like Jython/Java) not actually a Python-to-C convertor? And Pysco is just a different VM isn't it?
Pyrex is python plus access to C structures and type declarations. But
then the current implementation create intermediary C files.
Psyco is not a different VM, it's like the JIT of java. It's a Just In
Time compilers, ie it runs over the CPythonVM.
[...]
--
Yermat This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: rhmd |
last post by:
Just found Python and I love it. What an elegant language!
I would like to use it for various applications, but the
mathematical calculations are way too slow (a million sines 8 seconds
in Python vs. 2 seconds in Excel VBA), so was thinking of learning
enough C++ to do the number crunching in C++ and integrating the C++
routines with Python. My question:
My question:
Which compiler works best with Python?
I use Windows XP and 98. Have...
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: K_Lee |
last post by:
I documented the regex internal implementation code for both Tcl and Python.
As much as I like Tcl, I like Python's code much more.
Tcl's Stub interface to the external commands is confusing to
outsider. I still don't get why the stub interface is needed.
One aspect I don't understanding about python is that the Python
language itself is object oriented and all the internal is implement
as C object. Why not C++ object?
|
by: Christian Seberino |
last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python?
Python's design is godly. I'm wondering if Ruby's is godly too.
I've heard it has solid OOP design but then I've also heard there are
lots of weird ways to do some things kinda like Perl which is bad for me.
Any other ideas?
|
by: Thomas Reichelt |
last post by:
Moin,
short question: is there any language combining the syntax, flexibility and
great programming experience of Python with static typing? Is there a
project to add static typing to Python?
Thank you,
--
greetz tom
| |
by: Michael Scarlett |
last post by:
There is an amazing article by paul graham about python, and an even
better discussion about it on slashdot. The reason I point this out,
is the more I read both articles, the more I realised how we would be
mutilating the language with that god forsaken @ decorator.
I don't know about the rest of you, but I learned python and fell in
love with its syntax and simplicity. Python - just works. So please
GVR. Don't complicate it. Leave it as...
|
by: BOOGIEMAN |
last post by:
Well that's it, how do I make Windows Application with Python ???
Is there simple way that works 100% ? How can I rework visual design
done in VS 2003 to use it for my python program ?
|
by: xeys_00 |
last post by:
I posted a article earlier pertaining programming for my boss. Now I am
gonna ask a question about programming for myself. I just finished my
first C++ Class. Next semester is a class on encryption(and it's
probably gonna be a math class too). And finally back in programming in
the fall with C++ and Java 1. The C++ will cover pointers, and linked
lists, sorting algorithms, etc... I run linux and OS X. I have read in
the old days that C was...
|
by: jwrweatherley |
last post by:
I'm pretty new to python, but am very happy with it. As well as using
it at work I've been using it to solve various puzzles on the Project
Euler site - http://projecteuler.net. So far it has not let me down,
but it has proved surprisingly slow on one puzzle.
The puzzle is: p is the perimeter of a right angle triangle with
integral length sides, {a,b,c}. which value of p < 1000, is the
number of solutions {a,b,c} maximised?
Here's my...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |