Opened 12 years ago

Closed 8 years ago

#7250 closed defect (invalid)

cached_function broken for builtin functions

Reported by: nthiery Owned by: cwitty
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: misc Keywords: cached function
Cc: craigcitro, boothby, rlm Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


This used to work before #6937:

    sage: f = cached_function(sage.structure.element.is_RingElement)
    sage: f(1)

That's used at one spot in the category code (but we can disable it temporarily)

Change History (2)

comment:1 Changed 8 years ago by nbruin

  • Report Upstream set to N/A

On 5.6b1 I get

sage: f = cached_function(sage.structure.element.is_RingElement)
sage: f(1)
sage: f(False)
sage: f(True)
sage: f(x)
sage: f(0)
sage: f.get_cache()
{((1,), ()): True, ((x,), ()): True, ((False,), ()): False}

so it seems to work well enough now. Of course, f(0) and f(True) give funny answers because this the computed value is not a function on equality classes of the inputs (i.e., 0==False and 1==True, but is_RingElement doesn't have the same value on them).

The documentation of cached_function could do a better job of pointing out this gotcha (it mentions arguments should be hashable, but not that different but equal arguments will trigger cache use).

Anyway, I guess this ticket can be closed or be used to improve the documentation.

comment:2 Changed 8 years ago by mhansen

  • Milestone changed from sage-5.11 to sage-duplicate/invalid/wontfix
  • Resolution set to invalid
  • Status changed from new to closed

I would say that it can be closed.

Note: See TracTickets for help on using tickets.