IIRC it's an old micro-optimization; this was a common idiom at Zope. But I think it's way overused -- people believe it works so they do it all the time, even for code that's not performance sensitive, just because it's become a habit. (Like "register" in C in the '80s.)On Tue, Oct 27, 2015 at 10:55 AM, Yury Selivanov <yselivanov.ml@gmail.com> wrote:Serhiy,
On 2015-10-27 1:45 PM, Serhiy Storchaka wrote:
There is known trick to optimize a function:
def foo(x, y=0, len=len, pack=struct.pack, maxsize=1<<BPF):
...
def foo(x, SENTINEL=object()):...
def foo(x):static SENTINEL = object()...