Skip to content

Conversation

davidhewitt
Copy link
Member

I was looking again at #5350 and realised it could be worth optimizing the Drop implementation of Py<T> to bias towards the case when the thread is attached, as I think this is a common scenario.

As part of the optimizations I split the code into a fast and #[cold] path, and also removed #[track_caller] as the panic only happens if the reference pool is not enabled.

Copy link

codspeed-hq bot commented Sep 19, 2025

CodSpeed Performance Report

Merging #5454 will improve performances by ×3

Comparing davidhewitt:py-drop (06f3235) with main (cb9111b)

Summary

⚡ 2 improvements
✅ 96 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
collect_generic_iterator 105.4 ms 95.8 ms +10.03%
drop_many_objects 11.4 µs 3.8 µs ×3

@davidhewitt davidhewitt added this pull request to the merge queue Sep 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 22, 2025
@davidhewitt davidhewitt added this pull request to the merge queue Sep 27, 2025
Merged via the queue into PyO3:main with commit da618c7 Sep 27, 2025
43 checks passed
@davidhewitt davidhewitt deleted the py-drop branch September 27, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants