Skip to content

Conversation

dg-pb
Copy link
Contributor

@dg-pb dg-pb commented Apr 29, 2025

@ZeroIntensity ZeroIntensity added the performance Performance or resource usage label Apr 29, 2025
Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

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

Makes sense to me (nice analysis in the issue!) but let's let other performance dedicated folks weigh in

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Jun 18, 2025

I'm overall in favour of doing this. Though I wonder if there will be code that relies on the fact that ints between -x to 256 are cached and everything else isn't. I'm somewhat worried some weird code out there relying on the current int interning will break. Does anyone know?

(This includes both C API code and Python code).

@ericsnowcurrently
Copy link
Member

I'm somewhat worried some weird code out there relying on the current int interning will break.

IMHO, at a certain point we can't accommodate every way people might rely on some implementation detail. In this specific case we've been fairly clear in documentation (and elsewhere) about not relying on identity. We'll also point out the change in the release notes. Again IMHO, as long as are thoughtful about impact, we should expect that users (taking advantage of impl-specific details like this) take responsibility for adjusting their own code. "We're all consenting adults."

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.

Sorry about the inactivity here @dg-pb -- I just remembered this PR after someone was discussing the small integer cache.

I think we should add a news entry and then land this for 3.15. It's technically an internal-only change, but people do notice when things become immortal.

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.

Thanks, this looks good to me.

@Fidget-Spinner Are you happy with this?

@Fidget-Spinner
Copy link
Member

Don't wait on me, I'm not blocking it!

@ZeroIntensity ZeroIntensity merged commit 7ce25ed into python:main Sep 24, 2025
45 checks passed
@dg-pb dg-pb deleted the NSMALLPOSINTS1025 branch September 24, 2025 21:44
n-albert-e added a commit to n-albert-e/cpython that referenced this pull request Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance or resource usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants