On Wed, Jul 22, 2009 at 4:33 PM, Dragan Djuric<draga...@gmail.com> wrote: > > I've just read in the Stuart's book that multimethod dispatching on > something other than Java inheritance is rarely used. It seems to me > that there is a huge potential for their use in something that I do, > so I'd add "yet" to his words. Anyway, what I would ask someone from > the core team, or someone else that knows the internals is: > How fast the multimethods dispatch performs with large taxonomies > compared to Java inheritance or small taxonomies? For example, a 1000 > or thousands elements in different taxonomies (or even a million?). Is > it designed to perform well in such cases? >
Multimethod dispatch cost is the dispatch function + a single hashmap lookup. If there is no match, there is a single one-time matching process, the results of which are cached per multimethod. Ancestor/descendant relationships are precalculated on modification of the hierarchy, so isa? (for keywords) is a map lookup, not a tree walk. All caches are invalidated on any modification to the hierarchy. There is currently no per-call-site caching, nor any optimization for specialized cases (e.g. single dispatch). So, it is not going to be as fast as Java inheritance. OTOH, the model is simple - what you see is what you get, and scalability of the hashmaps from 1000s to millions is also good, and again something you can directly try out. Rich --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---