Skip to content

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Sep 1, 2025

On main the following leaks:

$ ./python -X showrefcount -c 'import _random; s = _random.Random(); t = type(s); t._random = s'
[42 refs, 26 blocks]

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one idea.

@serhiy-storchaka
Copy link
Member

Wait, why is _random.Random mutable?

@ZeroIntensity
Copy link
Member

Probably because it would break code to change that.

@serhiy-storchaka
Copy link
Member

It became mutable in 3.9. I think this is a bug.

@picnixz
Copy link
Member Author

picnixz commented Sep 1, 2025

It became mutable in 3.9. I think this is a bug.

I was also surprised but I just didn't want to break stuff here.

@kumaraditya303
Copy link
Contributor

It became mutable in 3.9. I think this is a bug.

Yes, I think adding IMMUTABLE flag was missed while conversion, it shouldn't be a mutable type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants