C API: Change immutable objects? :-o
mcherm at destiny.com
Fri Aug 2 18:17:08 CEST 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
More information about the Python-list