George Sakkis <george.sak...@gmail.com> writes:

> I'm working on some graph generation problem where the node identity
> is significant (e.g. "if node1 is node2: # do something) but ideally I
> wouldn't want to impose any constraint on what a node is

I'm not sure if it helps in your case, but you can easily turn off the
optimization by subclassing from the string type:

>>> class mystr(str):
...   pass
...
>>> s = mystr('x')
>>> s
'x'
>>> s is 'x'
False

Since mystr can have additional functionality on top of str, the
caching doesn't apply to the subclass instances.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to