Is python not good enough?

J

John Nagle

David said:
There are efficient implementations of dynamic programming languages
which do not rely on declaration (if by declaration you mean typing
declaration), even when available:

http://strongtalk.googlecode.com/svn/web site/history.html

See also:

http://www.avibryant.com/2008/05/those-who-misre.html

Yes, that's my point.

Psyco was a good first step. The big win with Psyco is that it
generally can recognize when a variable is an integer or floating
point number, and generate hard code for that. It doesn't do much
for the rest of the language. Psyco is really a kind of JIT compiler.
Those are useful, but in some ways limited.

To go beyond that, global analysis is needed. A big bottleneck
in Python is that too much time is spent doing dictionary lookups
for things that could be bound at compile time. So the next big
win is figuring out which classes definitely don't have any hidden
dynamism. A global check is needed to see if any external code
messes with the attributes of a class or its functions from outside
the function. Most of the time, this is the case. Once that's
been done, the class's module can be analyzed for optimization.

If the class doesn't use "setattr", etc. to add attributes to
itself, then the class can be "slotted", with a C++ like structure for
the class members and functions.

Global analysis also has to determine the class hierarchy; what inherits
from what. It may be necessary to implement "object" as an abstract class
with a huge number of virtual functions, so that "duck typing" will work.
That's a space cost, but not a time cost.

Caller/callee type inference is useful to determine the potential types
of parameters. Often, analysis of all the calls to a function will determine
the types of many of the paraeters. Then, those parameters can be hard-typed
at compile time.

You can go this far without the restrictions Shed Skin imposes, such as
the restriction that lists must be homogeneous. If you do impose that
restriction, array processing becomes much faster. Type inference for
array elements is hard when arrays are computed from other arrays, so
that's a huge simplification.

Yes, you can't use "eval" to get at existing variables. But in Python,
you don't really need to.

John Nagle
 
D

David Cournapeau

  Yes, that's my point.

Compilation with global type inference may be a good way to speed up
python, but it is not the only way. Your claim about lookups does seem
to contradict how the various efficient implementations of dynamic
languages work. For example, the V8 engine deal with dynamic
attributes without static analysis:

http://code.google.com/apis/v8/design.html

So JIT may be limited, but I don't think it applies to the examples
you have given. Maybe static analysis ala stalin is needed for very
fast execution.

I don't claim any knowledge on those technologies, but my impression
is that other forces held back a fast python implementation, in
particular compatibility with C extensions. For example, I know no
fast implementation of dynamic languages which do not rely on garbage
collection: if this is indeed true, it may mean that retrofitting a gc
everywhere is needed, but doing so without breaking C extensions is
hard (if at all possible ?). And certainly, one of the big reason for
the python success is easy interface with C. Maybe interfacing with C
is the real reason for holding back python implementations ?

cheers,

David
 
P

Paul Rubin

David Cournapeau said:
And certainly, one of the big reason for
the python success is easy interface with C. Maybe interfacing with C
is the real reason for holding back python implementations ?

The CPython/C API is not terrible but it's not all that easy to use.
For example, it's very easy to make reference counting errors. Other
language FFI's that I've used avoid that problem to some extent. It's
true that CPython has quite a few existing C modules that would require
rework if the API were to change incompatibly. But I think a different
(better) API wouldn't stop people from writing new modules.
 
T

Terry Reedy

Compilation with global type inference may be a good way to speed up
python, but it is not the only way. Your claim about lookups does seem
to contradict how the various efficient implementations of dynamic
languages work. For example, the V8 engine deal with dynamic
attributes without static analysis:

http://code.google.com/apis/v8/design.html

Reading that, I notice a couple of things.

1. Like Psycho, V8 trades space for time. Given that space is now
expanding more than time is shrinking, this is more sensible in general
than it was a decade ago. Given Javascript programs are usually small
and work with small objects, this is even more sensible for Javascript
than for some Python programs.

2. It compiles to object code rather than byte code. If the only target
is standard 32/64 bit Intel/AMD processors, this is quite sensible. Does
V8 have, for instance, Cray versions?

Guido wants the reference version to be runnable on everything with a C
compiler and maintainable and upgradeable by volunteers who are not
assembler experts (which I believe are getting more rare).

tjr
 
S

Stefan Behnel

Paul Rubin, 17.01.2010 05:06:
The CPython/C API is not terrible but it's not all that easy to use.
For example, it's very easy to make reference counting errors. Other
language FFI's that I've used avoid that problem to some extent.

Other languages don't have Cython.

It's true that CPython has quite a few existing C modules that would require
rework if the API were to change incompatibly.

"quite a few" sounds a bit too weak here. Some of the existing C extensions
have become reasons to use Python in the first place. Think of NumPy, for
example, and the whole scipy environment. Think of the
performance-to-usability ratio of cElementTree and lxml. Think of the huge
body of Cython code in Sage. Imagine what the set of dbm modules (or even
the entire standard library) would be without external C libraries and C
extensions.

The C-API and the ton of modules that use it are pretty vital for Python.
AFAICT, Py3 is pretty much a virgin platform when it comes to scientific
computing, mostly because NumPy still wasn't adapted to the changes in the
C-API. They even consider rewriting parts of it in Cython a simpler way to
solve this issue than trying to port the code itself. This shows that any
change to that API may have a tremendous effect on the usability of Python
as a whole.

But I think a different
(better) API wouldn't stop people from writing new modules.

"Writing new modules" may not be enough.

Stefan
 
B

Blog

I'm a little confused.
Is python not good enough?
for google, enhance python performance is the good way better then
choose build Go language?

Go language try to merge low level, hight level and browser language.

Those I'd like to see it on python..
Have you not heard about the "Unladen Swallow" project from google?
There's a new PEP coming up which will propose google's codebase to be
merged with Py3k, resulting in superior performance.
 
A

alex23

Blog said:
Have you not heard about the "Unladen Swallow" project from google?
There's a new PEP coming up which will propose google's codebase to be
merged with Py3k, resulting in superior performance.

This kind of worries me for a number of reasons:
* unladen is _way_ too immature and unproven a project to replace the
current implementation,
* Google themselves have stressed they're only concerned with
improvements that benefit their use cases, such that
* other benchmarks appear to perform _worse_ under unladen, and
* has the project even posted substantive enough gains to warrant
this change? that didn't seem to be the situation when I last checked
* so far, the speed improvements have come at a cost of significantly
higher memory use (i believe it was ~10 times that of CPython at one
point)

I dunno, I kinda feel about Unladen Swallow the exact same way I do
about Go: if it wasn't a Google project, I really doubt it would be
getting the attention it is (over the other performance enhancement
projects: cython, psyco2, pypi et al)
 
P

Phlip

Go language try to merge low level, hight level and browser language.

Go uses := for assignment.

This means, to appease the self-righteous indignation of the math
professor who would claim = should mean "equality"...

....you gotta type a shift and 2 characters for a very common operator.

Pass!
 
T

Tim Chase

Phlip said:
Go uses := for assignment.

This means, to appease the self-righteous indignation of the math
professor who would claim = should mean "equality"...

...you gotta type a shift and 2 characters for a very common operator.

Pass!

Pass?! no...Pascal! :)

-tkc
 
D

David Cournapeau

This means, to appease the self-righteous indignation of the math
professor who would claim = should mean "equality"...

Much more likely, this is part of the stated goal of making go very
easy to analyse (to build tools and so that go is very fast to
compile), as stated in its FAQ.

cheers,

David
 
P

Phlip

Except that it doesn't. := is a declaration.

Ah, and that's why Go is easy for cheap parsers to rip.

Tx all!

I was formerly too mortified to proceed - now I'm back in the Go camp.
They fixed the hideous redundancy of Java without the ill-defined
scope issues of Python & Ruby, and without the tacky little 'var' of
JavaScript!
 
S

Steven D'Aprano

Go uses := for assignment.

This means, to appease the self-righteous indignation of the math
professor who would claim = should mean "equality"...

...you gotta type a shift and 2 characters for a very common operator.

I doubt it has anything to do with "the math professor". Any maths
professor will tell you that, in mathematics, = is used for both
assignment and equality, since in maths they are the same thing.

And besides, equality testing is no less common than assignment. To
appease the "self-righteous indignation of the C coders", we have to type
== instead of = for a very common operator. No matter what convention you
use, you're going to upset some group of people.

Seriously, I programmed in Pascal for many years, and typing := for
assignment is not a burden.
 
M

MRAB

Phlip said:
Go uses := for assignment.

This means, to appease the self-righteous indignation of the math
professor who would claim = should mean "equality"...

...you gotta type a shift and 2 characters for a very common operator.

Pass!
If I were going to list what I didn't like about Go, that wouldn't be
one of them!
 
S

Simon Brunning

2010/1/25 Albert van der Horst said:
If Go was to compete with anything, they would have give it a name
that was Googleable. ;-)

If they want it Googleable, it will be. ;-)
 
A

Albert van der Horst

It is not at all clear that -- despite some comments to the contrary --
the Go developers are intending to compete with Python. Go seems much
more intended to compete with C++/Java. If they're successful, we may
eventually see GoPython. ;-)

As far as I can tell, Go was not intended to compete with anything.
It was their own itch they scratched.
Then they opened it to the world, which I applaud.

If Go was to compete with anything, they would have give it a name
that was Googleable. ;-)

Groetjes Albert
 

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

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top