Skip to content

Attribute cache silently disabled after 1000 class edit, leading to poor performance #156339

Description

@perrinjerome

Bug report

Bug description:

After the changes from #114900 modifying a class more than 1000 times causes the attribute cache to be permanently disabled for that class. This was done to solve a crash when a class is modified more than 2**32 times ( #113462 )

It seems this number (1000) is too low for some real case applications.

I initially observed this as a ~50% performance regression in ERP5 performance tests when updating from python3.11 to python3.13. ERP5 is an application where classes are generated dynamically based on some configuration and some classes are modified more than 1000 times in the "normal" generation process.

This seems to also affect odoo, another ERP application, for this they resorted to using ctypes to reset the class version attribute ( odoo/odoo#275640 )

My suggestion would be to use a much higher number before disabling the cache, 1000 is low.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions