LOAD_ATTR/METHOD deopts on dict versions too quickly #431
Fidget-Spinner
started this conversation in
Ideas
Replies: 3 comments 9 replies
-
How have you defined Why would we want hidden classes for Python? We have real classes. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Doesn't |
Beta Was this translation helpful? Give feedback.
2 replies
-
I don't understand what is the problem here.
This seems to be exactly what we want. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Edit: this was previously titled "Dictkeys version should be tied to dict state. However, I realised I messed up and was focusing on the wrong aspect of the problem. See #431 (reply in thread)
Currently, we invalidate and increment dict keys version for a type every time one of its object adds/removes an attribute.
In the above example, we don't need to update the dictkeys version of
A()
. We should just let it keep its old version. Dictkeys should be tied to individual state.The benefit of this is that our method/attribute specialisations can handle more dynamic code. Especially those that modify attributes frequently.
Currently, I'm not too sure what approach we need to achieve this. The current behavior is a side effect of the key sharing nature of dictionaries and it's very memory efficient. So anything modifying that may cause CPython to consume more memory.
If we were to implement hidden classes. This would be significantly easier as it would just be a version tied to the hidden class. However, I understand from #6 that hidden classes are not being pursued.
Beta Was this translation helpful? Give feedback.
All reactions