Hi
are there any future perspectives for Python to be as fast as java? i
would like to use Python as a language for writing games.
best regards
krystian
Nov 30 '05
53 3448
Steven Bethard wrote: David Rasmussen wrote: Faster than assembly? LOL... :)
Faster than physics? ;-)
I think the claim goes something along the lines of "assembly is so hard to get right that if you can automatically generate it from a HLL, not only will it be more likely to be correct, it will be more likely to be fast because the code generator can provide the appropriate optimizations".
I think this is just a restatement of existing motivations for using
high-level languages and compilers. My impression is that PyPy takes
inspiration from work which showed that run-time knowledge can
sometimes produce code that is better optimised than that produced by a
compiler.
That said, when everyone starts showing off their favourite benchmarks,
it might be more interesting not to parade some festival of arithmetic
yet again. Where more recent versions of the Java virtual machines have
improved is in their handling of object memory allocation, amongst
other things, and merely scoffing that Java is slow (by pulling
specific/specialised extension packages out of the hat) fails to
acknowledge the potential for similar improvements (and others) in
Python, especially where programs involving plain objects - as opposed
to numbers, and where no conveniently available and wrapped C/C++
package exists for the task - are concerned.
Paul
Harald Armin Massa wrote: Dr. Armin Rigo has some mathematical proof, that High Level Languages like esp. Python are able to be faster than low level code like Fortran, C or assembly.
I am not wise enough to understand that proof.
Maybe I understood those papers totally wrong and he was saying something totally different.
Here is a paper of Armin explaining his psycology: http://psyco.sourceforge.net/theory_psyco.pdf
Heck, Python has at least one programmer who is computer scientist and
knows how to draw commutative diagrams :)
Steven Bethard wrote: David Rasmussen wrote:
Harald Armin Massa wrote:
Dr. Armin Rigo has some mathematical proof, that High Level Languages like esp. Python are able to be faster than low level code like Fortran, C or assembly.
Faster than assembly? LOL... :)
I think the claim goes something along the lines of "assembly is so hard to get right that if you can automatically generate it from a HLL, not only will it be more likely to be correct, it will be more likely to be fast because the code generator can provide the appropriate optimizations".
OTOH, you can almost certainly take automatically generated assembly code and make optimizations the code generator wasn't able to, thanks to knowing more about the real semantics of the program.
Yeah, but the other important part of the claim has to do with just that: the
real [runtime] semantics of the program.
Hand optimization happens before runtime, obviously, whereas the HLL->assembly
conversion can happen once the program is running and more info is known about
the actual sets of data being operated on, the frequence of function calls, i.e.
where the need for optimization actually exists. The optimization could even
happen multiple times to adapt over time, or to allow multiple optimizations for
different classes of data so that the code that actually executes is highly
specialized.
So, yeah, knowledge of the runtime behavior can allow a hand-optimized version
to run faster than a static, automatically-generated version, but knowledge of
the runtime behavior could also allow a dynamic code generator to even beat the
hand-optimized version.
-Dave
>Faster than assembly? LOL... :)
why not? Of course, a simple script like "copy 200 bytes from left to
right" can be handoptimized in assembler and run at optimum speed.
Maybe there is even a special processor command to do that.
I learned that there was one generation of CPUs which had effectively a
command to copy X bytes from left to right; but a specific version of
that CPU did this command slower then a loop in certain situations.
Some newer generations of that CPU and even some competitors CPU had
that command implented correctly, and it was indeed faster than the
loop.
Now: is it rather likely that for a single programm a programmer is
able to get it right for all CPUs?
It even gets more complicated. The human mind is able to consider a
certain amount of things at once, sth. like on-chip-cache or
short-term-memory.
Now with an ever growing complexity of processors, with cache lines,
partyparallelex ecution, branchpredictio n, out of order execution,
multilevelcachi ng, hypermetathread ing ... it may be that the usual
availaible human brain is no longer capable of really knowing what
happens.
My guess is that the average code speed of a Rigopy could indeed be
higher than the average code speed of the average assembler programmer.
Harald
David Rasmussen wrote: Harald Armin Massa wrote:
Dr. Armin Rigo has some mathematical proof, that High Level Languages like esp. Python are able to be faster than low level code like Fortran, C or assembly.
Faster than assembly? LOL... :)
I don't see why this is so funny. A good C compiler with optimization
typically produces better code than an equivalent assembly language
program. As compilation techniques improve this gap is likely to widen.
There's less and less reason to use assembler language with each passing
year.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
Hi!
Harald Armin Massa wrote: And I could see real development just from watching the BDFL: 3 years ago PyPy was 2000times slower then CPython, and Guido was joking "and that number is growing", this year there were not officially negated romours that sometime maybe PyPy could be the reference implementation of Python; and also reports that PyPy is only 18 times slower then CPython.
well, currently PyPy is around 9-11 times slower than CPython. Since a
few weeks ago we are now able to switch stacklessness on and off at
compile time to be able to have an interpreter that supports very deeply
recursive algorithms, if that is needed.
Cheers,
Carl Friedrich Bolz
David Rasmussen wrote: Frithiof Andreas Jensen wrote:From the speed requirement: Is that correspondance chess by any chance??
Regular chess at tournament time controls requires speed too. Any pure Python chess program would lose badly to the best C/C++ programs out there now.
I would also like to see Half Life 2 in pure Python.
True, but so what? Why did you suddenly change the discussion to
require "pure" Python? And please define "pure" Python, given that the
interpreter and many builtins, not to mention many widely used extension
modules, are coded in C? And are you not allowed to use any of the
performance-boosting techniques available for Python, like Pyrex or
Psyco? Why such restrictions, when these are things Python programs use
on a daily basis: these are *part* of Python, as much as the -O switch
on the compiler is part of C/C++.
Okay, let's compare a "pure" Python program (if you can define it in any
meaningful, practical way) with a "pure" Java program, running on a
non-JIT interpreter and with optimizations turned off (because, of
course, those optimizations are umm... somehow.. not "pure"...?) .
Judging by the other posts in this thread, the gauntlet is down: Python
is faster than Java. Let those who believe otherwise prove their point
with facts, and without artificially handcuffing their opponents with
non-real-world "purity" requirements.
-Peter
Harald Armin Massa wrote: Faster than assembly? LOL... :)
why not? Of course, a simple script like "copy 200 bytes from left to right" can be handoptimized in assembler and run at optimum speed. Maybe there is even a special processor command to do that.
I learned that there was one generation of CPUs which had effectively a command to copy X bytes from left to right; but a specific version of that CPU did this command slower then a loop in certain situations. Some newer generations of that CPU and even some competitors CPU had that command implented correctly, and it was indeed faster than the loop.
Now: is it rather likely that for a single programm a programmer is able to get it right for all CPUs?
It even gets more complicated. The human mind is able to consider a certain amount of things at once, sth. like on-chip-cache or short-term-memory.
Now with an ever growing complexity of processors, with cache lines, partyparallelex ecution, branchpredictio n, out of order execution, multilevelcachi ng, hypermetathread ing ... it may be that the usual availaible human brain is no longer capable of really knowing what happens.
global optimizers for non-C languages can sometimes produce faster code
than human C coders, also when those optimizers use C as an intermediate
language...
</F>
David Rasmussen wrote: Frithiof Andreas Jensen wrote:
From the speed requirement: Is that correspondance chess by any chance??
Regular chess at tournament time controls requires speed too. Any pure Python chess program would lose badly to the best C/C++ programs out there now.
I would also like to see Half Life 2 in pure Python.
There's nothing like "pure" Python. Python depends on a lot of libs,
most of them being coded in C++ or C (or assembly FWIW). The common
scheme is to use Python for the logic and low-level libs for the
critical parts.
And FWIW, I'd like to see any similar game in "pure" Java !-)
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Steven Bethard wrote: David Rasmussen wrote: Faster than assembly? LOL... :)
Faster than physics? ;-)
I think the claim goes something along the lines of "assembly is so
hard to get right that if you can automatically generate it from a HLL,
not only will it be more likely to be correct, it will be more likely to
be fast because the code generator can provide the appropriate
optimizations".
I think this is just a restatement of existing motivations for using
high-level languages and compilers. My impression is that PyPy takes
inspiration from work which showed that run-time knowledge can
sometimes produce code that is better optimised than that produced by
a
compiler.
That said, when everyone starts showing off their favourite
benchmarks,
it might be more interesting not to parade some festival of arithmetic
yet again. Where more recent versions of the Java virtual machines
have
improved is in their handling of object memory allocation, amongst
other things, and merely scoffing that Java is slow (by pulling
specific/specialised extension packages out of the hat) fails to
acknowledge the potential for similar improvements (and others) in
Python, especially where programs involving plain objects - as opposed
to numbers, and where no conveniently available and wrapped C/C++
package exists for the task - are concerned.
Paul This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Svein Ove Aas |
last post by:
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...
|
by: Maboroshi |
last post by:
Hi I am fairly new to programming but not as such that I am a total beginner
From what I understand C and C++ are faster languages than Python. Is this
because of Pythons ability to operate on almost any operating system? Or is
there many other reasons why?
I understand there is ansi/iso C and C++ and that ANSI/ISO Code will work on
any system
If this is the reason why, than why don't developers create specific Python
Distrubutions...
|
by: Neuruss |
last post by:
It seems there are quite a few projects aimed to improve Python's
speed and, therefore, eliminate its main limitation for mainstream
acceptance.
I just wonder what do you all think?
Will Python (and dynamic languages in general) be someday close to
compiled languages speed?
What will be the future of Psyco, Pypy, Starkiller, Ironpython and all
the other projects currently on development?
|
by: surfunbear |
last post by:
I've read some posts on Perl versus Python and studied a bit of my
Python book.
I'm a software engineer, familiar with C++ objected oriented
development, but have been using Perl because it is great for pattern
matching, text processing, and automated testing. Our company is really
fixated on risk managnemt and the only way I can do enough testing
without working overtime (which some people have ended up doing) is by
automating my...
|
by: Michael Tobis |
last post by:
Someone asked me to write a brief essay regarding the value-add
proposition for Python in the Fortran community. Slightly modified to
remove a few climatology-related specifics, here it is.
I would welcome comments and corrections, and would be happy to
contribute some version of this to the Python website if it is of
interest.
===
| |
by: abhinav |
last post by:
Hi guys.I have to implement a topical crawler as a part of my
project.What language should i implement
C or Python?Python though has fast development cycle but my concern is
speed also.I want to strke a balance between development speed and
crawler speed.Since Python is an interpreted language it is rather
slow.The crawler which will be working on huge set of pages should be
as fast as possible.One possible implementation would be...
|
by: 63q2o4i02 |
last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning
Python the past few months and like it very much. A few years ago I
had an AI class where we had to use Lisp, and I absolutely hated it,
having learned C++ a few years prior. They didn't teach Lisp at all
and instead expected us to learn on our own. I wasn't aware I had to
uproot my thought process to "get" it and wound up feeling like a
moron.
In learning Python I've...
|
by: Jerry Fleming |
last post by:
Hi,
I have wrote a game with python curses. The problem is that I want to
confirm before quitting, while my implementation doesn't seem to work.
Anyone can help me?
#!/usr/bin/python
#
# Brick & Ball in Python
# by Jerry Fleming <jerryfleming@etang.com>
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 375 open ( -3) / 3264 closed (+26) / 3639 total (+23)
Bugs : 910 open ( +3) / 5851 closed (+20) / 6761 total (+23)
RFE : 217 open ( -1) / 220 closed ( +3) / 437 total ( +2)
New / Reopened Patches
______________________
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |