473,289 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Performance of Python builtins

Is there any place outside the actual C source for Python that has
information about the performance of Python's built-in operations? For
example, I'd *expect* list.append to be O(1), and I hope that list[i]
is O(1), but I don't really know that for sure, since it would depend
a lot on the internal implementation.

I'm really only asking this for curiosity's sake --- more as a
reasonable, non-trollish version of the "Python is slow" post than
anything. :-) I've never really had any problems with the performance
of Python code that I couldn't solve by either changing my algorithm
or, if all else has truly failed, rewriting in C or Pyrex.

What I'd like to see is something like http://svn.python.org/projects/pytho...s/listsort.txt
where Python's sorting algorithm is described, except with the focus
on other built-in constructs.

Thanks!
Jun 27 '08 #1
6 1355
mi***********@gmail.com writes:
Is there any place outside the actual C source for Python that has
information about the performance of Python's built-in operations?
Really, just the source code and the general culture. It's not in the
docs; that would be a pretty rare thing.
For example, I'd *expect* list.append to be O(1), and I hope that
list[i] is O(1), but I don't really know that for sure, since it
would depend a lot on the internal implementation.
list[i] is O(1). list.append is amortized O(1) but on some calls can
take much longer. Basically list.append preallocates some extra space
for further appends but when you use up the extra space there is some
copying.
I'm really only asking this for curiosity's sake --- more as a
reasonable, non-trollish version of the "Python is slow" post than
anything. :-) I've never really had any problems with the performance
of Python code that I couldn't solve by either changing my algorithm
or, if all else has truly failed, rewriting in C or Pyrex.
"You can fix your Python program's performance problems by rewriting
it in C" is not that convincing an answer to a concern that Python is
slow ;-).
Jun 27 '08 #2
On May 25, 7:35*pm, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
miller.pau...@gmail.com writes:
Thanks for your reply. I guess I'll have to go source diving to truly
answer the question.
"You can fix your Python program's performance problems by rewriting
it in C" is not that convincing an answer to a concern that Python is
slow ;-).
Wasn't meant to be. But, it is a credit to Guido that, beyond the
pain inherent in coding in C, there's relatively little pain involved
in writing an extension module.
Jun 27 '08 #3

<mi***********@gmail.comwrote in message
news:d7**********************************@k37g2000 hsf.googlegroups.com...
| Is there any place outside the actual C source for Python that has
| information about the performance of Python's built-in operations?

Unfortunately no. Guido does not want to put guarantees in the language
definition, so there is no urgency to document this. An auxiliary doc
might be accepted. But the people who could write such a thing are busy
doing otherwise. Certainly, no one has volunteered to write *and update*
such.

Jun 27 '08 #4
On May 25, 9:43*pm, "Terry Reedy" <tjre...@udel.eduwrote:
<miller.pau...@gmail.comwrote in message

news:d7**********************************@k37g2000 hsf.googlegroups.com...
| Is there any place outside the actual C source for Python that has
| information about the performance of Python's built-in operations?

Unfortunately no. *Guido does not want to put guarantees in the language
definition, so there is no urgency to document this. *An auxiliary doc
might be accepted. *But the people who could write such a thing are busy
doing otherwise. *Certainly, no one has volunteered to write *and update*
such.
I see. Just to be clear, though, I wasn't looking for "guarantees" as
such, like (I believe) the STL sometimes provides. I was just looking
for some idea of what current implementations' performance
characteristics are.

I suppose I could probably create such a resource. Keeping it updated
would be another thing entirely, since I don't really want to monitor
every single commit to Python's svn repository. Hypothetically, if
someone made such a document, do you think it could be arranged for
that person to be notified whenever CPython's implementation changes
to invalidate it?
Jun 27 '08 #5
On May 25, 6:19 pm, miller.pau...@gmail.com wrote:
Is there any place outside the actual C source for Python that has
information about the performance of Python's built-in operations? For
example, I'd *expect* list.append to be O(1), and I hope that list[i]
is O(1), but I don't really know that for sure, since it would depend
a lot on the internal implementation.

I'm really only asking this for curiosity's sake --- more as a
reasonable, non-trollish version of the "Python is slow" post than
anything. :-) I've never really had any problems with the performance
of Python code that I couldn't solve by either changing my algorithm
or, if all else has truly failed, rewriting in C or Pyrex.

What I'd like to see is something likehttp://svn.python.org/projects/python/trunk/Objects/listsort.txt
where Python's sorting algorithm is described, except with the focus
on other built-in constructs.
http://wiki.python.org/moin/TimeComplexity is a start.
>
Thanks!
Jun 27 '08 #6
On May 25, 11:05*pm, Benjamin <musiccomposit...@gmail.comwrote:
http://wiki.python.org/moin/TimeComplexityis a start.
Awesome. That's pretty much what I was after!
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
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...
226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
46
by: Scott Chapman | last post by:
There seems to be an inconsistency here: Python 2.3.2 (#1, Oct 3 2003, 19:04:58) on linux2 >>> 1 == True True >>> 3 == True False >>> if 1: print "true" ....
39
by: Marco Aschwanden | last post by:
Hi I don't have to talk about the beauty of Python and its clear and readable syntax... but there are a few things that striked me while learning Python. I have collected those thoughts. I am...
176
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? ...
3
by: Michael Hoffman | last post by:
I was compelled to write this today for some reason. builtins = """__import__ abs basestring bool callable chr classmethod cmp compile complex delattr dict dir divmod enumerate eval execfile...
105
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.