[Python-Dev] method dispatch vs. switching (pickle faster in 2.2 ?)
M.-A. Lemburg
mal@lemburg.com
Thu, 01 Nov 2001 10:09:11 +0100
Guido van Rossum wrote:
>
> > While hacking on an XML pickler, I found that pickle.py got nearly
> > twice as fast in 2.2 comparing to 2.1 and 2.0.
>
> What benchmark?
I was looking at the roundtrip speed of pickling a list of integers.
> > The code in pickle.py doesn't seem to have changed much. Anybody
> > know where that speedup came from ? Can somebody on another
> > (non-Linux) system please verify this.
>
> I believe DOM nodes are now new-style classes, for better or for worse
> (it might create problems when combining with classic mixins). Could
> that explain it?
No. I'm writing my own little beast here which does not use DOM,
expat or sgmlop.
The results of the approach which tries to avoid Python
function calls are interesting. I moved from the usual
switch strategy of dispatching to instance methods to a
large for-loop with lots of "if x is y: ...". While I suspected
the latter to be faster on average, I found that this is
not the case. I still have to investigate where the performance
goes, but the result kind of surprised me.
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company: http://www.egenix.com/
Python Software: http://www.lemburg.com/python/