On Thursday, August 22, 2013 2:36:49 PM UTC-7, Simon King wrote:
>
>
> We have lazy_string and lazy_format. Note that #14585 suggest a cython 
> version of them. 
>
> Yes, I'm aware of those :-) and that should alleviate costs somewhat. 
However, a call

verbose(lazy_string("computing %s x %s ...",self.nrows(),self.ncols()))

would still result in the creation of a (somewhat cheaper) lazy string 
object, and the self.nrows() and self.ncols() method calls, even in cases 
where the verbosity is not required. That's a difference between verbose 
logging and exception raising: In the former case we know at the position 
of invocation whether the call will have an effect, whereas in the latter 
we don't have access to the context that will determine if the exception 
gets caught or printed.

That's why I think the cost is a little less acceptable for verbose 
messages. The code SHOULD read:

if (verbose.level > ...): verbose("....")

which is of course a bit awkward to type (but it's still a one-liner!). 
That's why I thought that it might be feasible to write some inline 
function or macro that would produce the desired code while keeping the 
convenience of putting a single statement in the source.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to