"Martin v. Loewis" wrote: > > > Wouldn't it make sense to enable the byte code compiler to take the > > above construct and turn it into a dictionary based switch statement > > ? > > That won't work. You cannot know what type "x" has, so you don't know > in advance how "x == 'one'" is evaluated. But you do know that x won't change from one compare to the next, so a single dictionary lookup could replace the equality tests (provided that x is hashable). As mentioned in the posting: the compiler probably has to be given some extra information to enable this sort of optimization. I'm not sure how the information could be "encoded", though. Suggestions are appreciated, as always :-) What do you think about the general idea, BTW ? -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4