#16316: cached_function and cached_method for unhashable elements
-------------------------------------+-------------------------------------
       Reporter:  saraedum           |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  minor              |    Milestone:  sage-6.3
      Component:  misc               |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Julian Rueth       |    Reviewers:  Peter Bruin, Travis
Report Upstream:  N/A                |  Scrimshaw
         Branch:                     |  Work issues:
  u/saraedum/ticket/16316            |       Commit:
   Dependencies:  #16251             |  83944fabe78c5561f0cc5b0845d5e8bdb30098c2
                                     |     Stopgaps:
-------------------------------------+-------------------------------------
Changes (by tscrim):

 * commit:  7a9a6b2a3e4a68bfd3c9d8d6556a883e1d1161e0 =>
     83944fabe78c5561f0cc5b0845d5e8bdb30098c2
 * branch:  u/tscrim/ticket/16316 => u/saraedum/ticket/16316


Comment:

 Replying to [comment:31 saraedum]:
 > It's a very good idea to include the description in the summary of
 `cachefunc.pyx`. But I also think it should be in `SageObject._cache_key`;
 if somebody is wondering what it is good for, that is the first place
 where they will look for it. It is a duplication of docstrings but I hope
 it is acceptable.

 It's a private method only used in one place, so the chances of someone
 finding it randomly are very slim, but okay, it doesn't really matter.

 > I made a few changes to your commit:
 >  * I removed some debug statements.

 Whoops, forgot about those.

 >  * Your changes to `_cache_key` change the current behaviour. Say you
 have a tuple of a polynomial over the rationals and a p-adic number. The
 old version would only call `_cache_key` of the p-adic number and leave
 the polynomial. Your version unpacks both which is unnecessary. I restored
 my version of the code.
 >  * The default implementation of `_cache_key` should raise an error. If
 somebody calls it (misunderstanding what it is good for), then it makes
 sense to warn people that they did something wrong: the code in
 `SageObject._cache_key()` will never be executed in a legitimate context.
 I do not mind raising a `TypeError` instead of a `NotImplementedError`.

 Restoring your branch so I can look again.
 ----
 New commits:
 
||[http://git.sagemath.org/sage.git/commit/?id=b41c4554ddcc9e25fc293fbee386468848e6ee0d
 b41c455]||{{{restore previous version of _cache_key() in
 cachefunc.pyx}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=37aa276dbbf3b842cf6ec2718f01da46f41f7384
 37aa276]||{{{reverted changes which treated _cache_key like an
 attribute}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=5586f567789776b2760a199eeb0fedc8e5b45f75
 5586f56]||{{{removed debug output}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=83944fabe78c5561f0cc5b0845d5e8bdb30098c2
 83944fa]||{{{Restored old version of SageObject._cache_key() but raising a
 TypeError instead of a NotImplementedError.}}}||

--
Ticket URL: <http://trac.sagemath.org/ticket/16316#comment:36>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to