# The mechanics of dispatch

**URL:** https://discourse.julialang.org/t/the-mechanics-of-dispatch/1484
**Category:** General Usage
**Created:** [January 14, 2017, 6:29pm UTC](https://discourse.julialang.org/t/the-mechanics-of-dispatch/1484 "2017-01-14T18:29:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)
#### Post date: [January 14, 2017, 6:29pm UTC](https://discourse.julialang.org/t/the-mechanics-of-dispatch/1484/1 "2017-01-14T18:29:28Z")

</div>

I’d like to understand the mechanics of runtime dispatching with untyped or partially-typed arguments a bit better. I found some useful information [here](https://groups.google.com/forum/#!topic/julia-users/fEQszkhapsc) and [here](https://groups.google.com/forum/#!topic/julia-users/38pKvFP0ynM), with the money quotes being

> It does a full method signature dispatch match at runtime if the types can’t be concretely inferred at compile time. - Jameson

> If you do end up in a situation where type inference can’t figure out what method to call, dispatch can get kind of slow, but it’s still comparable to method calls in Python or Ruby. - Stefan

And the [dev docs](http://docs.julialang.org/en/stable/devdocs/functions/#compiler-efficiency-issues) were informative.

What is the algorithm for dispatching? For that matter, which data structure is used for the method tables? Of course, the first call with a given type tuple is slow, but how are the subsequent calls done? Are they cached via a hash-table, or does Julia iteratively go through the method table at every call?

---

<div class="post-metadata">

### Author: ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)
#### Post date: [January 14, 2017, 6:50pm UTC](https://discourse.julialang.org/t/the-mechanics-of-dispatch/1484/2 "2017-01-14T18:50:47Z")

</div>

As far as I’m aware, the current approach was contributed in [https://github.com/JuliaLang/julia/pull/17212](https://github.com/JuliaLang/julia/pull/17212).
