# Dispatch time using \`Val\` is an order of magnitude slower than looking up with \`Dict\`

**URL:** <https://discourse.julialang.org/t/dispatch-time-using-val-is-an-order-of-magnitude-slower-than-looking-up-with-dict/3543>\
**Category:** Internals & Design\
**Created:** [May 5, 2017, 5:28pm UTC](https://discourse.julialang.org/t/dispatch-time-using-val-is-an-order-of-magnitude-slower-than-looking-up-with-dict/3543 "2017-05-05T17:28:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 5, 2017, 6:04pm UTC](https://discourse.julialang.org/t/dispatch-time-using-val-is-an-order-of-magnitude-slower-than-looking-up-with-dict/3543/2 "2017-05-05T18:04:32Z")

</div>

1. You must not use `Val` this way in real code. And that’s exactly because

2. Dispatch is fundamentally more complex than a dict look up because type matching is much more complex than hash lookup and direct value comparison. Dict lookup also doesn’t need to worry about multiple matches/specifity/ambiguity. It may be possible to make dispatch matches dict lookup performance but it’ll never be better and will in general be much worse.

---

_[View the full topic](https://discourse.julialang.org/t/dispatch-time-using-val-is-an-order-of-magnitude-slower-than-looking-up-with-dict/3543)._
