Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Tuning & Debugging > Time Measurement & Optimization > Dispatch >
Mathematica > Data Manipulation > Date & Time > Time Measurement & Optimization > Dispatch >

Dispatch

Dispatch
generates an optimized dispatch table representation of a list of rules. The object produced by Dispatch can be used to give the rules in .
  • The use of Dispatch will never affect results that are obtained, but may make the application of long lists of rules much faster.
  • Lists of rules are usually scanned sequentially when you evaluate an expression like . Rules such as and , which cannot simultaneously apply, need not both be scanned explicitly. Dispatch generates a dispatch table which uses hash codes to specify which sets of rules need actually be scanned for a particular input expression.
  • Lists of rules produced by assignments made with and are automatically optimized with dispatch tables when appropriate.
Create a dispatch table from a list of rules:
The result after replacements is the same:
Dispatch may be much faster for a long list of rules:
Create a dispatch table from a list of rules:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
The result after replacements is the same:
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
 
Dispatch may be much faster for a long list of rules:
In[1]:=
Click for copyable input
Out[1]//Short=
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
New in 2
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF