Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68046

Re: Python performance

From Marko Rauhamaa <marko@pacujo.net>
Newsgroups comp.lang.python
Subject Re: Python performance
Date 2014-03-08 19:48 +0200
Organization A noiseless patient Spider
Message-ID <87lhwktwdd.fsf@elektro.pacujo.net> (permalink)
References <290bb6ed-a17e-45e3-8ff7-e58bb50e66a6@googlegroups.com>

Show all headers | View raw


JCosta <generalcosta@gmail.com>:

> I did some work in c# and java and I converted some application to
> Python; I noticed Python is much slower than the other languages.
>
> Is this normal ?

Yes. The main reason is the dot notation, which in C through Java is
implemented by the compiler as a fixed offset to a memory structure.
High-level programming languages such as Python implement it through a
hash table lookup.

That's the price of keeping everything dynamic: the structural content
is free to change any time during the execution of the program. I have
heard (but not experienced first-hand) that some ingenious heuristic
optimizations have made Common Lisp code come close to C-style
performance. Google was gung ho about repeating the feat on Python, but
seem to have given up.

The second costly specialty of Python is the way objects are
instantiated. Each object is given a "personalized" dispatch table. That
costs time and memory but is extremely nice for the programmer.

In a word, Python is a godsend if its performance is good enough for
your needs. For other needs, you have other programming languages, and
you buy the performance dearly.

Java is a great programming language, as C# must also be. However, for
the needs where you need to drop out of Python, one must ask if you
weren't better off writing some core parts in C and integrating them
with Python.


Marko

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python performance JCosta <generalcosta@gmail.com> - 2014-03-08 04:53 -0800
  Re: Python performance Chris Angelico <rosuav@gmail.com> - 2014-03-09 00:24 +1100
  Re: Python performance Tim Chase <python.list@tim.thechases.com> - 2014-03-08 07:40 -0600
  Re: Python performance Marko Rauhamaa <marko@pacujo.net> - 2014-03-08 19:48 +0200
  Re: Python performance JCosta <generalcosta@gmail.com> - 2014-03-08 10:30 -0800
    Re: Python performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-08 18:49 +0000
  Re: Python performance Ned Batchelder <ned@nedbatchelder.com> - 2014-03-08 13:56 -0500

csiph-web