ANN.: Beta 1.0 of Weak Reference Extension Module is nowavailable

Martin von Loewis loewis at informatik.hu-berlin.de
Sun Nov 19 15:57:19 EST 2000


shindich at my-deja.com writes:

> Alex is absolutely correct. Only those objects that are being weak
> referenced will be checked. On top of that, the check is a lookup in
> the STL's map, which is a log(n).

This is actually one of the problems I have with this patch - use of
C++ and STL. I think most of the code could could be written in C
without loss of cleanliness or expressiveness. Using C++ classes might
be acceptable for P3k; I doubt any C++ code will be accepted into the
core of Python 2.x.

Wouldn't it be easier to use a Python dictionary instead of an STL
map?  I'd be curious which one wins on performance - the Python
dictionary should have constant lookup time on average, whereas an STL
map will have logarithmic time.

Regards,
Martin

P.S. I believe the statement 

> Only those objects that are being weak referenced will be checked

is slightly incorrect. It should be rather

  Only those objects that are of types for which there are instances
  that are being weak referenced will be checked

So as soon as one object of a type is weak-referenced, deallocation
costs are paid for all objects of that type. In particular, if you
create weak references to, say, instance objects, you'd pay during
deallocation of any instance object, whether that is weak referenced
or not.



More information about the Python-list mailing list