#14862: Compositions accept any input
-------------------------------------+-------------------------------------
Reporter: stumpc5 | Owner: sage-combinat
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.13
Component: combinatorics | Resolution:
Keywords: composition, | Merged in:
FindStat | Reviewers:
Authors: | Work issues: provide a test in the
Report Upstream: N/A | constructor
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
I wouldn't have expected this at first blush, but after reading
`Composition.__classcall_private__` it's pretty obvious why
in terms of performance, `Composition` should not be called directly:
{{{
sage: timeit("Composition([1,2,3,4])",number=100000)
100000 loops, best of 3: 8.01 µs per loop
sage: timeit("Compositions()([1,2,3,4])",number=100000)
100000 loops, best of 3: 6.8 µs per loop
sage: C=Compositions()
sage: timeit("C([1,2,3,4])",number=100000)
100000 loops, best of 3: 4.64 µs per loop
}}}
so perhaps the best solution is indeed to deprecate `Composition` as an
entry in the global namespace?
Note that the reported behaviour in the ticket still needs fixing. The
currently attached patch doesn't solve the problem below. I expect that
the fix has to go into the `__init__` rather than into the
`classcall_private`.
{{{
sage: Compositions()('ASDF')
['A', 'S', 'D', 'F']
sage: Compositions()('ASDF').parent()
Compositions of non-negative integers
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/14862#comment:19>
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/groups/opt_out.