[Python-Dev] 2.5 slower than 2.4 for some things?

ocean ocean at m2.ccsnet.ne.jp
Tue Jun 12 14:15:49 CEST 2007


> I've had a report from a user that Plex runs about half
> as fast in 2.5 as it did in 2.4. In particular, the
> NFA-to-DFA conversion phase, which does a lot of
> messing about with dicts representing mappings between
> sets of states.
>
> Does anyone in the Ministry for Making Python Blazingly
> fast happen to know of some change that might have
> pessimised things in this area?

Hello, I investigated. On my environment, consumed time is

E:\Plex-1.1.5>py24 plex_test2.py
0.710999965668

E:\Plex-1.1.5>py25 plex_test2.py
0.921999931335

And after I applied this patch to Plex/Machines, (make `Node' new style
class)

62c62
< class Node:
---
> class Node(object):

E:\Plex-1.1.5>py24 plex_test2.py
0.401000022888

E:\Plex-1.1.5>py25 plex_test2.py
0.350999832153

So, probably hash, comparation mechanizm of old/new style class has changed.
# improved for new style class, worse for old style class. Maybe optimized
for new style class?

Try this for minimum test.

import timeit

init = """
class Class:
 pass
c1 = Class()
c2 = Class()
"""

t1 = timeit.Timer("""
c1 < c2
""", init)

t2 = timeit.Timer("""
hash(c1)
hash(c2)
""", init)

print t1.timeit(1000)
print t2.timeit(1000)



More information about the Python-Dev mailing list