mrocklin/multipledispatch — pull request #29 by mrocklin (2014-07-29 22:03:54+00:00)
Title: Provide a switch to turn off reordering 

Fixes https://github.com/mrocklin/multipledispatch/issues/7

Dispatchers store type signatures in a list. Given any input this input is checked against this list *in order* and the first match succeeds. So that this is consistent with inheritance this list must be ordered very carefully. In fact it is a topological sort of a particular DAG.

Currently we recompute this list on every additional signature. Sadly this can become expensive if the number of signatures becomes very high. Furthermore it is wasteful because we only need to compute the order at the end.

This PR introduces two functions, `halt_method_resolution` and `restart_method_resolution` which turn off and on this behavior. As a result code like the following should be much faster than without these calls.

```Python
halt_method_resolution()

@dispatch(...)
def func(...):
pass

import more_dispatched_functions

restart_method_resolution()
```

These functions could use better names.