GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-132657: Improve performance in specialize_dict_access_hint() via adding specialization for PY_GIL_DISABLED by benediktjohannes · Pull Request #144886 · python/cpython

Conversation

@benediktjohannes

@benediktjohannes benediktjohannes commented Feb 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

General information

This PR aims to improve performance in specialize_dict_access_hint() via adding specialization for PY_GIL_DISABLED (refering to #142843 and #132657 by @eendebakpt and @nascheme, credits to them 👍).

Background

We apply deferred reference counting to the value when the object is owned by a different thread.

Further information

I've not tested and benchmarked this, it's just a code review, but I'm pretty confident that this is correct because it refers to #142843 and basically implements a similar change, but please correct me if I'm mistaken.

  • Issue: copy.copy and copy.deepcopy scale poorly with free-threading #132657

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@benediktjohannes
Improve performance in specialize_dict_access_hint() via adding speci…
82212b3
…alization for PY_GIL_DISABLED
@bedevere-app bedevere-app Bot added the awaiting review label Feb 16, 2026
@benediktjohannes benediktjohannes changed the title Improve performance in specialize_dict_access_hint() via adding specialization for PY_GIL_DISABLED gh-132657: Improve performance in specialize_dict_access_hint() via adding specialization for PY_GIL_DISABLED Feb 16, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 16, 2026
copy.copy and copy.deepcopy scale poorly with free-threading #132657
Closed
@benediktjohannes
benediktjohannes marked this pull request as draft February 16, 2026 18:22
@bedevere-app bedevere-app Bot removed the awaiting review label Feb 16, 2026
blurb-it Bot and others added 2 commits February 16, 2026 18:23
@blurb-it
📜🤖 Added by blurb_it.
613135a
@benediktjohannes
Update specialize.c
f79e41a
@benediktjohannes
benediktjohannes marked this pull request as ready for review February 16, 2026 18:25
@bedevere-app bedevere-app Bot added the awaiting review label Feb 16, 2026
@benediktjohannes
benediktjohannes marked this pull request as draft February 16, 2026 18:39
@bedevere-app bedevere-app Bot removed the awaiting review label Feb 16, 2026
@benediktjohannes
Update specialize.c
0c1e7e1
@benediktjohannes
benediktjohannes marked this pull request as ready for review February 16, 2026 18:56
@bedevere-app bedevere-app Bot added the awaiting review label Feb 16, 2026
@benediktjohannes

benediktjohannes commented Feb 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

This now also refers to PEP 810 and implements a change made in #142351 by @pablogsal, credits to him as well 👍 .

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@benediktjohannes
Update specialize.c
af7160b
@eendebakpt

eendebakpt commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

@benediktjohannes For performance related reviews please create a benchmark. We have to balance the performance improvement to increased complexity and (in this case) memory requirements (deferred objects are handled differently by the gc).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@benediktjohannes

benediktjohannes commented Feb 16, 2026

Copy link
Copy Markdown
Contributor Author

Hi @eendebakpt, thanks for your answer! I already thought of that comment, but my thought was that a Benchmark seems unnecessary to me in this case because changes like these were already done in another place (see linked PRs). My thought was that this is understandable from looking at the code because I don’t have a testing build installed currently.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nascheme

nascheme commented Feb 16, 2026

Copy link
Copy Markdown
Member

My initial reaction is that this likely increases memory usage too much. The other PR enables deferred reference counting for objects accessed as global variables. It should be a likely that globals typically live for a long time and so it's okay to only free them when the GC runs (which is what happens when you used deferred reference counting).

When accessing objects via a dict, I suspect it's more likely those objects have a short lifetime. E.g. you might access it from the dict a number of times in a short time window, enough to enable specialization. However, the dict and the entry might be freed quickly after that.

This is all speculation though. You would have to run some benchmarks to see what the effect is.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benediktjohannes added 5 commits February 17, 2026 14:16
@benediktjohannes
Merge branch 'python:main' into patch-7
eaeffd7
@benediktjohannes
Update specialize.c
f408c67
@benediktjohannes
Update specialize.c
143dd0f
@benediktjohannes
Update specialize.c
a12c0e1
@benediktjohannes
Update specialize.c
a4030a9
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 6, 2026
@eendebakpt eendebakpt added the pending The issue will be closed if no feedback is provided label Oct 12, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review pending The issue will be closed if no feedback is provided

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@benediktjohannes @eendebakpt @nascheme
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.