Skip to content

implement PyStringMethods#3677

Merged
davidhewitt merged 1 commit intoPyO3:mainfrom
davidhewitt:string2
Dec 20, 2023
Merged

implement PyStringMethods#3677
davidhewitt merged 1 commit intoPyO3:mainfrom
davidhewitt:string2

Conversation

@davidhewitt
Copy link
Copy Markdown
Member

For #3382

There are some interesting bits going on in this PR:

  • to_str needs the GILPool to work for abi3 before Python 3.10, so I have added a #[cfg] on the corresponding PyStringMethods API.
  • I've introduced to_cow as a new API in PyStringMethods which is an alternative for users on abi3 before 3.10 (cc @alex)
  • I've added Py::to_str, Py::to_cow and Py::to_string_lossy as reads which can outlast the GIL lifetime, like we did for bytes (cf GIL-free references to Python data #2275)

@alex
Copy link
Copy Markdown
Member

alex commented Dec 20, 2023

Makes sense to me.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 20, 2023

CodSpeed Performance Report

Merging #3677 will degrade performances by 33.39%

Comparing davidhewitt:string2 (f4f3169) with main (8bd2972)

Summary

❌ 1 regressions
✅ 77 untouched benchmarks

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

Benchmarks breakdown

Benchmark main davidhewitt:string2 Change
extract_str_downcast_success 422.2 ns 633.9 ns -33.39%

Comment thread src/types/string.rs
Comment thread src/types/string.rs Outdated
Comment thread src/types/string.rs Outdated
Comment thread src/types/string.rs Outdated
@adamreichold adamreichold added this pull request to the merge queue Dec 20, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 20, 2023
@davidhewitt
Copy link
Copy Markdown
Member Author

We've had a little bit of flakiness with PyPy 3.8 previously so will retry in the hope it's not caused by this PR.

@davidhewitt davidhewitt added this pull request to the merge queue Dec 20, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 20, 2023
@davidhewitt
Copy link
Copy Markdown
Member Author

Hmm I'll try to investigate this later 🤔

@davidhewitt davidhewitt added this pull request to the merge queue Dec 20, 2023
@davidhewitt
Copy link
Copy Markdown
Member Author

I noticed that PyPy 3.8 succeeded in the second run (but failed in the first), so I think this is just the usual PyPy flakiness :(

Merged via the queue into PyO3:main with commit 43827e3 Dec 20, 2023
@davidhewitt davidhewitt deleted the string2 branch December 20, 2023 22:39
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.

3 participants