Skip to content

Specialising LOAD_ATTR for mutable class attributes #93657

Closed as not planned
Closed as not planned
@Fidget-Spinner

Description

@Fidget-Spinner

Currently the following code doesn't specialise:

from enum import Enum
class Color(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3

def f():
 for _ in range(10):
  Color.RED

f()

This use pattern is very common in enums and also the recommended way to check constants in pattern matching. Specialising for this all mutable class attributes should speed up those use cases.

Metadata

Metadata

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions