◐ Shell
clean mode source ↗

Message 174598 - Python tracker

Did you try moving the existing single-argument fast path to before the main if statement in _make_key? That is:

    if not kwds and len(args) == 1:
         key = args[0]
         key_type = type(key)
         if key_type in fasttypes:
             if typed:
                 return key, key_type
             return key

Such a special case is already present, but it's *after* a lot of the other processing *and* it doesn't fire when typed==True.

So instead of the simple 2-tuple creation above, you instead do the relatively wasteful:

    args + tuple(type(v) for v in args)