Ian Bicking: the old part of his blog

Functional python comment 000

Generic functions, or particularly RuleDispatch, accomplishes just this. Maybe like:

@generic
def insert_element(tree, el):
    raise NotImplementedError

@insert_element.when('tree.left is None or el < tree.left')
def insert_element_left(tree, el):
    insert_element(tree.left, el)

...

At least, I think that does what you want. I wouldn't bank on the performance of that algorithm ;) But the functionality is there, particular in RuleDispatch (which with arbitrary predicate dispatch is more general/powerful than what is being proposed for py3k). Well, I guess I'm not entirely clear on the intention f Pattern(left=None); I guess I'd express that as lambda tree: tree.left is None. I assume the distinction is primarily in a language like OCaml, where you can statically analyze aspects of patterns, which is not generally possible in Python.

Comment on Re: Functional Python
by Ian Bicking

Comments:

Is the reason that you don't bank on the performance ;) that eval()-ing the condition in quotes would be a bottleneck?

# Justin Bayer

It's not eval'd, it's compiled on import; it's just that doing that branching operation for every pass of a rather tight loop (in tree traversal) isn't an efficient way to do that operation.

# Ian Bicking

www.katalog.wesnoth.pl holifld.info/katalog www.elate.pl/cat/ marek.holewinski.pl/katalog www.strony.pinia.pl www.dobredomy.pl/katalog/ www.artefakt.pl/katalog/ katalog.programisci.com.pl strony.shaco.pl katalog.twojapraca.info www.katalog.gigante.pl www.kat.plusk.info k1024.toreuse.pl b2b.wroclaw.pl/katalog/ news.stylokna.pl ale.biurka.pl k1024.telewizorek.pl stop.perfectfresh.com kat.gigahurt.pl www.strony.prbox.pl katalog.gcity.pl ups.markpol.biz www.coolmarket.net/katalog

# Adim