XND#serializefunction is an instance method and not a class method like that in
NDT? For me its quite counter intuitive to see that it modifies
selfaccording to the value of the serialized string that it is passed. Might it not be better to implement it as a class method?
[Stefan Krah] Do you mean
deserialize? It is a class method:
"deserialize", (PyCFunction)pyxnd_deserialize, METH_O|METH_CLASS, NULL },
In Python you can also call class methods from instances, but the instance is not modified:
>>> x = Decimal("1.23") >>> y = x.from_float(100) >>> x Decimal('1.23') >>> y Decimal('100')
[Sameer Deshmukh] @stefan.krah question about NDT object deallocation:
You said that reducing the refcount of a NDT object 0 via
ndt_decref is supposed to be the only way of deallocating an NDT struct.
However in the python code I can see that you simply point to the default
PyObject_del for the deletion (without decreasing refcount). Can you please explain why this is so?
.tp_free = PyObject_Del is just the counterpart to
self = (NdtObject *)type->tp_alloc(type, 0)
It allocates and frees the *Python object structure*.
.tp_dealloc = (destructor) ndtype_dealloc is the part that deallocates the
ndt struct by calling
xnd-rubyand has future plans for XND in the Ruby community.