GC.calloc with random bits causes slowdown, also seen in built in AA
Michael Rynn
michaelrynn at optusnet.com.au
Thu Mar 11 23:31:20 PST 2010
>
>> So now the PyDict does not use calloc. and is faster than the built-in.
>> I added a few missing properties (length, opIndex)
> "public size_t size()" is the length you were looking for. Also, opIndex
> might crash if the key is not present. I don't write D2 code., but
> shouldn't opIndex return a pointer to the entry?
Thank you, I needed to improve my understanding the finer details of
this implementation.
// call opIndex, which must return the value type
// may throw exception
ValueType v = aa[key]; // only works for V opIndex(..)
ValueType* v = key in aa; // only works for V* opIn_r(..)
I should probably continue on this and support all the properties
mentioned in -
http://www.digitalmars.com/d/2.0/arrays.html#associative
This includes having a .length property.
PyDictD2 is now updated with a .get, and the length() returns the same as
size().
Also if the aim is to make a drop in replacement for the AA, the
AA should have an implementation available as a struct, (even have the
same .sizeof) , so it can be placed directly in other structs, local
variables and classes just like the built-in AA, and no other code will
have to change.
I am creating a new module based on PyDictD2, to this effect, hope to
have available ASAP, since it will be mainly refactoring. If I do not
finish it tonight, it will have to be next week.
When there is such a drop in replacement, it will be easier for others to
try it out in existing code and uncover quirks and limitations. Then
there might be benefits.
-- taf
Michael
More information about the Digitalmars-d
mailing list