mypy
d422b3db - [mypyc] Support explicit acyclic native classes that avoid gc (#20795)

Commit
132 days ago
[mypyc] Support explicit acyclic native classes that avoid gc (#20795) Use `@mypyc_attr(acyclic=True)` so that instances of the class don't participate in cyclic gc. This sped up a microbenchmark that just allocates lots of temporary objects by ~60%. Acyclic instances also use less memory, since there is no GC header. I did some manual testing beyond the added tests to ensure acyclic classes work as expected. We can later add support for inferring acyclicity automatically in some cases, but usually it will have to be explicitly declared. This was created using Claude Code.
Author
Parents
Loading