Skip to content
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

Add Py::drop_ref method #3871

Merged
merged 7 commits into from Feb 21, 2024
Merged

Add Py::drop_ref method #3871

merged 7 commits into from Feb 21, 2024

Conversation

juntyr
Copy link
Contributor

@juntyr juntyr commented Feb 19, 2024

Adds the Py::drop_ref method to explicitly drop a Py and immediately decrease the Python reference count if the GIL is already held.

Fixes #3870

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks! I have a couple of quick thoughts...

src/instance.rs Show resolved Hide resolved
src/instance.rs Outdated Show resolved Hide resolved
Copy link

codspeed-hq bot commented Feb 19, 2024

CodSpeed Performance Report

Merging #3871 will not alter performance

Comparing juntyr:py-drop-ref (5f35069) with main (0bb9cab)

Summary

✅ 67 untouched benchmarks

⁉️ 12 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main juntyr:py-drop-ref Change
⁉️ mapping_from_dict 327.8 ns N/A N/A
⁉️ extract_float_downcast_success 453.3 ns N/A N/A
⁉️ extract_float_extract_success 417.2 ns N/A N/A
⁉️ extract_int_downcast_fail 300.6 ns N/A N/A
⁉️ extract_int_downcast_success 642.2 ns N/A N/A
⁉️ extract_int_extract_success 606.1 ns N/A N/A
⁉️ f64_from_pyobject 405.6 ns N/A N/A
⁉️ list_via_downcast 157.2 ns N/A N/A
⁉️ list_via_extract 336.7 ns N/A N/A
⁉️ not_a_list_via_downcast 244.4 ns N/A N/A
⁉️ sequence_from_list 355.6 ns N/A N/A
⁉️ sequence_from_tuple 267.2 ns N/A N/A

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Overall I think the implementation and documentation for this is great! As a final step, could you please add a test? 🙏

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks very much! 🚀

@davidhewitt davidhewitt added this pull request to the merge queue Feb 21, 2024
Merged via the queue into PyO3:main with commit 885883b Feb 21, 2024
37 of 39 checks passed
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.

Py::drop_ref
2 participants