Group Abstract Group Abstract

Message Boards Message Boards

Performance tuning in Wolfram Language

POSTED BY: Leonid Shifrin
4 Replies
Anonymous User
Anonymous User
Posted 9 years ago

you said avoid patterns and symbolism then also to use efficient patterns?

did you know mathematica uses a form of hashing to search for symbols ? (associative arrays, like awk does)

the Mathematica books discuss efficiency as well. for example: Dispatch is an old feature which was built for efficiency

but you are right. besides "testing every equation", it would be useful to know what parts of Mathematica are doing and what they're Big O is.

In[2119]:= Unprotect[In, Out];

In[2120]:= Clear[In, Out];

In[2121]:= Protect[In, Out];

In[2122]:= $HistoryLength = 5;

In[2123]:= MemoryInUse[]

Out[2123]= foo

POSTED BY: Anonymous User

You can use patterns efficiently or not. Just like anything else. The only difference is that it is easier to construct inefficient patterns for users with less experience, which is why I generally suggest to avoid pattern-matching in performance-sensitive code in favor of other programming styles. A good reference on this subject is an old book by David Wagner "Power Programming with Mathematica: the kernel" from 1996.

POSTED BY: Leonid Shifrin

Glad that you found this useful. Just keep in mind that this is a direct repost of a post that is 6 years old, and as such, it can be a little dated.

POSTED BY: Leonid Shifrin

Thanks for sharing!

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard