On May 14, 10:01 pm, Simon King <simon.k...@uni-jena.de> wrote:
> Indeed, when I created the AttributeErrorMessage, it was suggested on
> trac to use LazyString instead. It turns out that a special purpose
> cythoned AttributeErrorMessage is faster, but I agree that in the
> general case (when it makes no sense to have a special purpose object)
> it totally makes sense to be a bit lazy.

Interesting! It turns out that the current implementation of
LazyFormat is slower than lazy_string. Both implementations can be
cythonized and significantly sped up if required:

sage: %timeit Exception(LazyFormat("unsupported operand parent(s) for
'%s': '%s' and '%s'")%('+',R,S))
1000000 loops, best of 3: 1.77 us per loop

It's even worse when you reuse the string (this is clear from the
implementation):

sage: gg=LazyFormat("unsupported operand parent(s) for '%s': '%s' and
'%s'")
sage: %timeit Exception(gg%('+',R,S))
100000 loops, best of 3: 11.5 us per loop

structure.parent and structure.element do use LazyFormat, so it may be
worthwhile fixing its implementation.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to