On Aug 17, 1:46 am, Mateusz Paprocki <matt...@gmail.com> wrote: > Hi, > > On 17 August 2011 09:50, Gilbert gede <gilbertg...@gmail.com> wrote: > > > So, for my Summer of Code project, I'm writing a submodule to generate > > equations of motion for multibody systems. Sometimes the expressions > > in these equations are very large. I'm finding some of these > > expressions are prohibitively large when printing. Here is an example > > of one element in one of the output matrices generated by my code: > >http://pastebin.com/Vs9qsXMb > > Generating the string for the entire matrix takes a few minutes > > (printing that string occurs in no appreciable time though). > > I also profiled the code when printing the complete matrix: > >http://pastebin.com/c8hhdc46 > > I'm not exactly sure what to make of the results of the profiling > > though. Has anyone else encountered issues like this? Or have any > > thoughts on the printing of large expressions? > > sstr() printer is pretty fast itself, compared e.g. to pretty printer. From > profiler output you can see that most time is spent in evaluating > sort_key(), which is used for providing platform independent sorting of > expressions. In case of expressions of that big size you may not want to > have them nicely ordered, so our printer should have an option for disabling > sorting at all (well almost, because it would use hash-based sorting > inherited from Add and Mul). > > btw. What branch are you working on and can you provide the input > expressions so that I can look into the issue? > > > > > Thanks, > > Gilbert > > > -- > > You received this message because you are subscribed to the Google Groups > > "sympy" group. > > To post to this group, send email to sympy@googlegroups.com. > > To unsubscribe from this group, send email to > > sympy+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/sympy?hl=en. > > Mateusz
I'm on the pydy branch from my github fork: https://github.com/gilbertgede/sympy This is what I used to generate that output: http://pastebin.com/tVUn9SBi Printing KM.mass_matrix also takes a long time; it's another one of the veyr large expressions that gets generated. It think _print_Add's _as_ordered_terms is what is calling sort_key? So perhaps a printer option to not use that method would help out? -Gilbert -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.