C API: Change immutable objects? :-o
frank.sonnenburg at biosolveit.de
Fri Aug 2 12:45:01 EDT 2002
>> I'm trying to speed up updating my PyObjects, e.g. PyFloat.
>> So instead of deleting the old object and creating a new one with my new
>> double value, i over-write the old value in the PyFloatObject-struct:
> You are a brave, brave man.
> I can't think of a reason why this wouldn't work (assuming you're not
> dumb enough to be keeping multiple references to the object and
> expecting old ones to retain their values, their hashes, or other such
> features). But that doesn't mean there isn't such a reason.
> But I ought to ask... the main thing you're saving is the time to
> allocate and deallocate the memory for the objects. Are you running a
> version of Python compiled with pymalloc? Because I believe that fairly
> recent changes have wrought significant gains in performance when
> working with large numbers of small objects.
> Anyway... good luck brave soul!
> -- Michael Chermside
Ok, i understand this as "keep your hands off!"
Anyway, i'm still experimenting. At first i will use "old-fashioned" style.
Thanks a lot!
More information about the Python-list