◐ Shell
clean mode source ↗

Message 256381 - Python tracker

[Emanuel Barry]
> In which circumstances does comparing two code objects
> (at function creation time, what's more) make any sense?

It makes closures efficient:

    >>> def f(x):
            def g(y):
                    return x + y
            return g

    >>> h = f(1)
    >>> i = f(2)
    >>> h.__code__ is i.__code__
    True