Talin wrote:

> In fact, I'd like to point out something that hasn't been brought up, 
> which is that in many cases having a closure rebind the switch cases 
> defeats the purpose of the thing. For example:
> 
>     def outer():
>        def inner(x):
>           switch(x):
>           case 1: ...
>           case 2: ...
>           case 3: ...
> 
>        return inner
> 
> If the switch cases are bound at the time that 'inner' is defined, it 
> means that the hash table will be rebuilt each time 'outer' is called. 

not if all cases are literals, as in your example.

and how common is this, really?  are you sure you're not arguing against 
a construct that is more efficient in many existing use cases, based on 
a single, mostly hypothetical use case ?

(after all, if you don't want Python to waste time optimizing things for 
you, you don't have to use a construct that does that...)

</F>

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to