On Sat, Jun 13, 2009 at 5:27 PM, William Stein<[email protected]> wrote: > > 2009/6/12 [email protected] <[email protected]>: >> >> I'm working on some code that is very computationally intensive. I'm >> pretty sure my algorithm is good, but I know that tiny differences in >> wording in sage can make a huge runtime difference. Is there any site/ >> blog/whatever that I could look at to find out what makes for fast >> sage code? I figure this is preferable to constantly spamming sage- >> support with optimization questions. >> > > In my experience, if you want to write really fast code using Sage or > any other software there is no substitute for putting in the work to > deeply understand the algorithms you are using and how they are > implemented. Nothing beats reading the source code, etc. If foo is > any Sage function one way to get started reading the sources for foo > is to type "foo?".
Just to add to William's comments, the command sage: foo? shows the online documentation of the function foo. To get the source code for foo, do sage: foo?? That is, type two question marks after the function name. Both foo? and foo?? also show the path to the source file in which foo can be found, so that should be an indication of where to look. In my experience, a choice of data structure is also important. For example, searching with a dictionary is usually way faster than implementing your own search algorithm. One needs to work on a case by case basis. -- Regards Minh Van Nguyen --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
