Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of inline Python function definitions

Tags:

A general question for someone that knows function definition internals better than I do.

In general, is there a performance trade off to doing something like this:

def my_function():
    def other_function():
        pass

    # do some stuff
    other_function()

Versus:

def other_function():
    pass

def my_function():
    # do some stuff
    other_function()

I've seen developers inline functions before to keep a small, single use function close to the code that actually uses it, but I always wondered if there were a memory (or compute) performance penalty for doing something like this.

Thoughts?