generates an optimized dispatch table representation of a list of rules. The object produced by Dispatch can be used to give the rules in expr/.rules.


  • 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 expr/.rules. Rules such as a[1]->a1 and a[2]->a2, 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.
  • Dispatch is treated as a raw object by functions like AtomQ and for purposes of pattern matching.
  • Normal converts a Dispatch to a list of rules.


open allclose all

Basic Examples  (2)

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:

Scope  (2)

Use Dispatch with pattern-based rules:

Create a dispatch from an association:

Properties & Relations  (2)

Dispatch is AtomQ:

Use Normal to convert a dispatch to a normal list of rules:

Wolfram Research (1991), Dispatch, Wolfram Language function, https://reference.wolfram.com/language/ref/Dispatch.html.


Wolfram Research (1991), Dispatch, Wolfram Language function, https://reference.wolfram.com/language/ref/Dispatch.html.


Wolfram Language. 1991. "Dispatch." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Dispatch.html.


Wolfram Language. (1991). Dispatch. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Dispatch.html


@misc{reference.wolfram_2023_dispatch, author="Wolfram Research", title="{Dispatch}", year="1991", howpublished="\url{https://reference.wolfram.com/language/ref/Dispatch.html}", note=[Accessed: 25-February-2024 ]}


@online{reference.wolfram_2023_dispatch, organization={Wolfram Research}, title={Dispatch}, year={1991}, url={https://reference.wolfram.com/language/ref/Dispatch.html}, note=[Accessed: 25-February-2024 ]}