Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated memory management #543
base: main
Are you sure you want to change the base?
Updated memory management #543
Changes from all commits
9abcd0d
6605842
931c352
a618f2a
b1bf61c
21f2e0b
20ab8f9
160c819
ce9d78c
6d89330
3bb7ccc
c0b091c
ab1f762
544d694
b4a1624
f0edb5b
22396dc
7d51fde
acfa546
18e08cc
532fbe0
52e92c0
efed734
ab8a895
30e4277
c3a4fe1
7bdc31f
460728b
d9c0f62
49d9381
e0d7792
715912f
20e45b6
86b29a4
944328d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flagging so it isn't forgotten - a link here to the
NSCopying
docs would be helpful, plus highlighting thatcopy
can return the same object as an optimisation if the object is immutable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry a bit that the mental load of following when we retain and release is a bit much now since the reader needs to think though the
__new__
method being invoked multiple times with the same pointer.Alternatives such as explicitly tracking a "Python refcount" might be easier to understand but would also add complexity.
Suggestions are welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this approach: if it's possible to deal with the situation immediately after the
copy
, that's definitely easier to follow than maintaining an extra refcount.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. An extra refcount starts to get into re-implementing garbage collection territory, and I'm not sure that's a game that is worth it. I'm comfortable with this as a known edge case, and documenting it with some related usage patterns and advice.