Python is faster than C

Andrew MacIntyre andymac at bullseye.apana.org.au
Sat Apr 3 19:36:19 EST 2004


On Sat, 3 Apr 2004, Armin Rigo wrote:

> This is a rant against the optimization trend of the Python interpreter.
>
> Sorting a list of 100000 integers in random order takes:
>
> * 0.75 seconds in Python 2.1
> * 0.51 seconds in Python 2.2
> * 0.46 seconds in Python 2.3
>
> Tim Peters did a great job optimizing list.sort().  If I try with a
> simple, non-stable pure Python quicksort implementation, in Python 2.3:
>
> * 4.83 seconds
> * 0.21 seconds with Psyco
>
> First step towards world domination of high-level languages :-)

{...}

> So this is not so much a plug for Psyco as a rant against the current
> trend of rewriting standard modules in C.  Premature optimization and
> all that.

{...}

> Protesting-ly yours,

While I certainly appreciate pysco and what it can do, I believe your
protest to be unreasonable as it denies better performance on platforms
that psyco doesn't yet (& probably never will) support.

Moreover, your protest about iterators is also unreasonable as people are
benefitting from the reduced memory consumption iterators and their ilk
bring (quite often accompanied by performance gains from not having to
thrash large amounts of RAM through pitiful caches).  As such, iterators
are a _different_ optimisation, and I hope that you can come to terms with
this and psycoise them too!

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen  ACT  2616
Web:    http://www.andymac.org/               |        Australia




More information about the Python-list mailing list