#14585: Make lazy_format and lazy_string faster
------------------------------+--------------------------
Reporter: SimonKing | Owner: robertwb
Type: defect | Status: needs_work
Priority: major | Milestone: sage-6.4
Component: coercion | Resolution:
Keywords: | Merged in:
Authors: Simon King | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
------------------------------+--------------------------
Comment (by nbruin):
Part of why `LazyFormat` seems so sluggish presently is the strategy how
it copies itself when asked to rebind. It will usually be cheaper to make
a fresh `LazyFormat` object (in other words, we should make the rebinding
just do that). The problem presently is that the use of `copy` leads to
the desperate act of using `__reduce__` (!) to do the copying. Much better
already:
{{{
sage: class A(str): pass
sage: a=A("a")
sage: %timeit copy(a)
100000 loops, best of 3: 13 µs per loop
sage: %timeit A(str.__repr__(a))
1000000 loops, best of 3: 558 ns per loop
sage: %timeit A("a")
10000000 loops, best of 3: 258 ns per loop
}}}
so at the very least we should use the latter incantation in
`LazyFormat.__mod__`, and it would be even nicer be able to get the string
value of a in a cheaper way.
--
Ticket URL: <http://trac.sagemath.org/ticket/14585#comment:34>
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.