On 30 May 2012 00:04, Aaron Meurer <[email protected]> wrote:
> On Tue, May 29, 2012 at 11:57 AM, Joachim Durchholz <[email protected]> 
> wrote:
>> Am 29.05.2012 07:10, schrieb Aaron Meurer:
>>
>>> _hashable_content generally contains
>>> other Basic objects. So what I really want is the "fully denested"
>>> _hashable_content, where each Basic object is recursively replaced
>>> with its _hashable_content.  I've no idea how expensive that would be
>>> to compute.
>>
>>
>> The behavior will be quadratic with number of levels of sets. This could
>> start to impact us on deeply nested expressions - not with anything a human
>> would enter, but if somebody wants to use SymPy from a script, this might be
>> different. (I'm talking of thousands of nesting levels.)
>> One way to set that might be to simplify x+0+0+...+0 (1000 terms, then retry
>> with 100,000 ;-) ).
>>
>> The downside of caching is that each mutator must invalidate the cached
>> hash. (Unless mutators are disallowed once an object is entered into a dict.
>> Or the mutable objects are really copy-on-write ones. I don't know whether
>> any of these paths is available already, or feasible if unavailable - we're
>> deep into Systems Programming Land here.)
>
> In Python, only immutable objects are hashable, and in SymPy, all
> Basic subclasses are immutable, so this isn't an issue.
>
One can easily cheat this rule:

class A(object):
    def __init__(self, immut1, immut2, mut):
       ...
    def __hash__(self):
        return hash((self.immut1, self.immut2))

For instance this can be a Manifold, that must be "immutable" as
mathematical object, however still be able to learn about new
coordinate systems defined on it.

I am mentioning it because I am not really sure what does this mean:
> In Python, only immutable objects are hashable
I suppose I can get some clarification that way.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to