A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2001-November/018561.html below:

[Python-Dev] optimizing simple function calls [was PEP 275 (switching)]

[Python-Dev] optimizing simple function calls [was PEP 275 (switching)]M.-A. Lemburg mal@lemburg.com
Mon, 12 Nov 2001 16:42:16 +0100
Neil Schemenauer wrote:
> 
> M.-A. Lemburg wrote:
> >     The current solution to this problem lies in using a dispatch
> >     table to find the case implementing method to execute depending on
> >     the value of the switch variable (this can be tuned to have a
> >     complexity of O(1) on average, e.g. by using perfect hash
> >     tables). This works well for state machines which require complex
> >     and lengthy processing in the different case methods. It does not
> >     perform well for ones which only process one or two instructions
> >     per case, e.g.
> >
> >     def handle_data(self, data):
> >         self.stack.append(data)
> 
> It would be nice if we could make simple methods like this faster.
> Maybe something like a special fast path for methods with no blocks and
> no variable or keyword arguments.  I think optimizing small functions
> would be a greater overall benefit to the average Python program.

Sure would, it's just that some of the overhead cannot be optimized
away, e.g. creation and initializing of frame objects, argument
formatting etc.

Perhaps there's some way to avoid all this overhead and maybe
not even leave the ceval loop... e.g. by preallocating frame
objects for often used code objects or improving their 
reuseability. Code objects could, for example, provide a
prefilled frame object template which then only needs to be 
copied onto a fresh frame object (via memcpy()) at frame init
time.

-- 
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