Skip to content

poor scaling of descriptors in free-threading #148906

@kumaraditya303

Description

@kumaraditya303

On the free-threaded build, attribute access through a user-defined __get__ descriptor scales poorly.

Reproducer

Benchmark added to Tools/ftscalingbench/ftscalingbench.py:

class MyDescriptor:
    def __get__(self, obj, objtype=None):
        return 42

    def __set__(self, obj, value):
        pass

class MyClassWithDescriptor:
    attr = MyDescriptor()

@register_benchmark
def descriptor():
    obj = MyClassWithDescriptor()
    for _ in range(1000 * WORK_SCALE):
        obj.attr

With 10 threads, Apple Silicon, free-threaded build:

descriptor          17.1x slower

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions