[Python-Dev] genexps slow? (original) (raw)
Michael Hudson mwh at python.net
Wed Mar 31 05:45:25 EST 2004
- Previous message: [Python-Dev] genexps slow?
- Next message: [Python-Dev] genexps slow?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Tim Peters" <tim.one at comcast.net> writes:
Resuming a generator function is a lot cheaper than calling a function, but there's still a non-trivial amount of code to get in and out of evalframe() each time, which the listcomp version gets to skip.
This is something that occurred to me a while ago: how many opcodes does a typical invocation of eval_frame actually execute? A little script told me that the median length of functions in Lib/*.py was 38 instructions (or 52 bytes) IIRC, but obviously a dynamic count is far more interesting. If the number is fairly small (and honestly, I have no idea), the set up and tear down code becomes much more significant than one might think.
I didn't think much about the code to get out of eval_frame.
Cheers, mwh
-- I love the way Microsoft follows standards. In much the same manner that fish follow migrating caribou. -- Paul Tomblin -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html
- Previous message: [Python-Dev] genexps slow?
- Next message: [Python-Dev] genexps slow?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]