<div><div>On Fri, Aug 12, 2011 at 1:49 PM, Peter V. Saveliev <span dir="ltr"><<a href="mailto:peet@altlinux.ru">peet@altlinux.ru</a>></span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I have a stream of objects, each of dictionary type....<br>
<br>I shoud take an action depending on event's 'type' (neigh[bor], link,<br>
address, route etc.) and 'action' (add, del) items.<br>
<br>
Now I see two ways:<br>
* build a tree of «if/elif» statements within one function<br>
* create a dictionary that points to different methods<br>
<br>
The issue is that a method call is slower that jump within one function.<br></blockquote><div><br></div>Is the overhead of a method call the biggest problem in your code?<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


But a dictionary lookup is faster than «if/elif» statements (if I have a<br>
lot of variants and do not want to rebuild B-like tree of «if»<br>
statements by hands).<br>
<br>
Is there a way to combine these methods? Can I create a dictionary of<br>
jump instructions?<br></blockquote><div><br></div><div>How would this be useful to someone writing a python program? Or put another way, if the Python interpreter had such a feature, what language feature would use it? Since there is no switch statement <a href="http://www.python.org/dev/peps/pep-3103/">http://www.python.org/dev/peps/pep-3103/</a> this seems premature optimization.</div>

<div> </div></div><div><div><font face="arial, helvetica, sans-serif">--- </font>Bruce</div><div>Follow <font face="arial, helvetica, sans-serif">me: <a href="http://www.twitter.com/Vroo" target="_blank">http://www.twitter.com/Vroo</a> <a href="http://www.vroospeak.com/" target="_blank">http://www.vroospeak.com</a></font></div>

<div></div><div></div></div></div><div><br></div>