Re [Python-Dev] object equality vs identity, in and dicts idioms and speed
Aahz Maruch
aahz@rahul.net
Fri, 4 Jan 2002 13:00:24 -0800 (PST)
Samuele Pedroni wrote:
> [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.
I'm slightly confuzzled here (no surprise given how little Java I know).
How does Jython know which Java class instance to refer to if there's
no mapping? If there is a mapping, how does it slow things down to
create an id every time a map gets created? (Yes, it'll chew up memory,
but Java uses so much memory already... ;-)
--
--- Aahz (@pobox.com)
Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
We must not let the evil of a few trample the freedoms of the many.