faster-cpython / ideas

1.67k stars 49 forks source link

Lazily create attributes that are created often, but read rarely. #674

Open markshannon opened 1 month ago

markshannon commented 1 month ago

There are objects that we create frequently that have attributes that are rarely used and can be computed lazily. We should compute these lazily to save the overhead of creating and destroying them in most cases.

Most of these attributes are mutable, so we still need a field for them. We can initialize the field to NULL and compute it on demand.

Others?