Re: __delitem__ affecting performance

2006-10-19 Thread Fredrik Lundh
Karl H. wrote: > Does anybody know why defining __delitem__ is causing the code to run > slower? It is not being called, so I don't see why it would affect > performance. probably because overriding portions of the internal sequence slot API (tp_as_sequence) means that Python needs to do full

__delitem__ affecting performance

2006-10-19 Thread Karl H.
Hi, I was performing some timing tests on a class that inherits from the built-in list, and got some curious results: import timeit class MyList(list): def __init__(self): list.__init__(self) self[:] = [0,0,0] def __delitem__(self,index): print 'deleting'