• Kevin Modzelewski's avatar
    Optimize slot_tp_getattr_hook · bfe7d79e
    Kevin Modzelewski authored
    ie the way that __getattr__ ends up getting called.  Two main optimizations:
    - switch the initial attribute access (ie checking to see the attribute exists
      before calling __getattr__) to use a non-throwing api.  For the typical case,
      even though the throwing would be a C API throw, the construction of the
      AttributeError is relatively expensive, and the object would be immediately
      discarded anyway.
    - add rewriting to the function
    
    They both roughly cut out half the overhead of accessing attributes on
    classes with __getattr__.
    bfe7d79e
55.py 703 Bytes