Re [Python-Dev] object equality vs identity, in and dicts idioms and speed
Samuele Pedroni
Samuele Pedroni" <pedroni@inf.ethz.ch
Fri, 4 Jan 2002 04:11:00 +0100
[Tim Peters]
> Mapping what to what? A fine implementation of id() would be to hand each
> new object a unique Java int from a global counter, incremented once per
> Python object creation -- or a Java long if any JVM stays up long enough
> that 32 bits is an issue <wink>.
The problem are java class instances, sir,
we use non-unique wrappers for them and identity is simulated.
We could use a table to make the wrappers unique but we have
potentially lots of them as you can imagine, jython people
actually use java classes <wink>. So the workaround
is to keep a table just for the java instances for which
someone has asked the id. We cannot win-win so
we try not to lose-lose. For simplicity we will
extend the table approach to everything.
If you have a win-win solution also in this case please ...
Our goal is compatibility but we will suggest
to avoid id as far as possible for production jython
code ...
regards