[xml-bindings]Proposal 2: __eq__ for Python node wrappers
- From: Marc-Antoine Parent <maparent acm org>
- To: xml-bindings gnome org
- Subject: [xml-bindings]Proposal 2: __eq__ for Python node wrappers
- Date: Tue, 2 Mar 2004 11:26:39 -0500
Another extension proposal: I often try to ascertain whether any two
nodes or even sometimes documents are identical. However, I cannot rely
on object equality, and not even on object equality of the underlying
PyCObject which may be different for the same node. (Solving the latter
is of course beyond the scope of this list, but I assume that I can
somehow access the PyCObject's pointer to the underlying pure C object
if I were to implement __eq__ in C.)
I suppose that changing __eq__ would also make it desirable to
implement a __hash__ method, based on the C object's pointer's
position; __ne__ is of course necessary.
Again, would that be considered a good thing?
(If so, we could even consider going further: Would we want to
implement a full __cmp__? For nodes within a document, it could be
defined by depth-first ordering, but that is much more difficult. It
also leaves open the question of what to do for nodes of different
documents... I guess that would have to rely on an ordering between
documents, which could only be arbitrary. But I am much less certain
that this is a good idea.)
Marc-Antoine
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]