Am Freitag, 15. September 2017 23:28:06 UTC+2 schrieb Travis Scrimshaw: > > > Why are you proposing local imports? If python puts a performance penalty >> on them (in fact a significant performance penalty), they should be >> avoided, no? >> >> It is a relatively small penalty, so when it is not in a tight loop, it > is useful to break out of those cyclic imports (and has better locality of > reference). >
Why does it matter whether the loop is tight or not? The profler says that for an extremely sparse matrix, a third of the time in MatrixSpace.matrix is spent in doing imports. And as it happens, a third of the time of creating the permutation matrix is spent in MatrixSpace.matrix. It's not that I'm doing these optimizations just for fun. I am applying >> many of these little maps very very very often. I am now optimizing those >> which I can and which are among the top offenders. Without this, my >> program will simply not finish in any reasonable time on my computer. >> >> In this case, it is a natural tight loop local and should not be there. > As I mentioned on the ticket, I think a way forward would be to do a check > for a _matrix_ attribute (which we might need to add to those classes). > However, there is something to be said about the *order* of the testing, > in that checking for lists/tuples is probably be more likely to happen and > should be higher on the checking order, which would probably make any > issues about local imports for you moot. > Warning: in the case at hand I am passing a dict with sparse set to true, which is currently the (implicit) "else" case. Of course, we can change the order of the tests, but that might make other people unhappy, no? I'm glad you are cross-checking this - many thanks! -- 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 https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.