There is a second problem, also, with the use of "verbose" in Cython code in the sage library. When "verbose" is called, the code for the verbosity mechanism decides whether to print the message based on the name of the module containing the calling function. Unfortunately this introspection mechanism doesn't work for Cython files. So if you are trying to debug Python module X, which calls code from Cython module Y, and you want to print only debugging messages from X, you actually get messages from Y as well. Common values for Y where this is a problem include sage.matrix.matrix_rational_dense. It's very tiresome when you're trying to fix a problem with (say) modular forms, and your debugging output is totally buried under hundreds of lines like "Using linbox echelon form modulo 2098901..."
David On 22 August 2013 23:19, Nils Bruin <[email protected]> wrote: > 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. -- 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.
