[Python-Dev] PEP 275: Switching on Multiple Values, Rev 1.2
Aahz Maruch
aahz@rahul.net
Fri, 23 Nov 2001 02:55:45 -0800 (PST)
[Yes, this should probably go to python-list, but after surgery I
haven't been on c.l.py for more than a month.]
M.-A. Lemburg wrote:
>
> Here is a new revision of the switch PEP. After this round and
> after Guido returns to python-dev, I intend to do one or two
> more rounds on python-list.
Here's a weird idea:
Given that the main problem we're trying to solve is the slowness of
dictionary dispatching to functions, how about adding an "inline"
keyword or function?
For example (assuming it's a function):
def handle_data():
self.append(data)
dispatch_dict["foo"] = handle_data
class C:
def read_input(self):
data = "foo"
value = handle_data
inline(dispatch_dict[value])
Note carefully that handle_data() has no paramaters. This solution
would be somewhat more expensive computationally than the switch
construct, but it ought to be cheaper than doing an actual function
call.
--
--- Aahz (@pobox.com)
Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
We must not let the evil of a few trample the freedoms of the many.