E&S CVS Commit: PyProtocols - Massive overhaul of indexing and inequality handling to linearize the speed

pje at eby-sarna.com pje at eby-sarna.com
Wed Apr 27 01:50:00 EDT 2005


Module Name:    PyProtocols
Committed By:   pje
Date:           Sun Apr 24 07:24:57 UTC 2005

Modified Files:
        PyProtocols/src/dispatch: strategy.py
        PyProtocols/src/protocols/tests: test_dispatch.py

Log Message:
Massive overhaul of indexing and inequality handling to linearize the speed
of defining new methods.  Before this change, method definition time would
rapidly increase as the number of tests applied to a given argument
expression increased.  In some informal tests, defining 500 methods using
unique inequalities (==1, ==2, etc.) used to take about 2 seconds.  Now,
you can define 5000 such methods in the same amount of time, and the rate
stays linear at about 2500 methods/second on my PC, including the time to
parse and compile the expressions.

The primary downside to this change is a possible loss of stability or
functionality.  It passes all the tests, but it's quite possible that I'm
missing important tests.  It also makes the code even harder to understand
than it already was, and I'm not sure *I* understand it any more!  In fact,
I think I stopped understanding it a few hours before I finished this
change.  However, I hope that with a few cleanup refactoring passes I'll be
able to document and/or re-understand it, and maybe be more certain that it
is correct in all circumstances, not just the ones I've thought of so far
to test.

Oh, and speaking of such things, I also fixed Jay Parlar's other reported
bug: the weird "make_index" thing that I thought was an import circularity.
It's in fact to do with using 'dispatch.as()' while executing another
decorator.  Nested assignment advisors don't work so well; guess we should
move to Python 2.4 ASAP.


To view diffs of this commit, you can use the following URL(s):
http://cvs.eby-sarna.com/PyProtocols/src/dispatch/strategy.py.diff?r1=1.39&r2=1.40
http://cvs.eby-sarna.com/PyProtocols/src/protocols/tests/test_dispatch.py.diff?r1=1.48&r2=1.49

To generate a diff of this commit:
cvs rdiff -r1.39 -r1.40 PyProtocols/src/dispatch/strategy.py
cvs rdiff -r1.48 -r1.49 PyProtocols/src/protocols/tests/test_dispatch.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



More information about the source-changes mailing list