-
Notifications
You must be signed in to change notification settings - Fork 758
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 TryExtend
trait
#4664
base: main
Are you sure you want to change the base?
Add TryExtend
trait
#4664
Conversation
@@ -0,0 +1,23 @@ | |||
//! A trait for extending a collection with elements from an iterator, returning an error if the operation fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find a obvious file to add this trait to so I created a new one. Suggestions are welcome.
1a4ce61
to
3cd380f
Compare
I'm unsure whether I'm in favor of this, but I don't want specialization. We used to rely on it but removed it a couple of years ago. The problem with specialization (even the min version) is that it has soundness issues when it comes to lifetimes and it also has no realistic path towards stabilization. Also, you can add a compatibility shim for |
Alternatively I could add 2 methods to PyList & PyDict; |
3cd380f
to
79c8296
Compare
79c8296
to
06d8289
Compare
CodSpeed Performance ReportMerging #4664 will improve performances by 16.34%Comparing Summary
Benchmarks breakdown
|
This PR adds a
TryExtend
trait that is similar to thestd::iter::Extend
trait except it is failable. Currently implemented forPyList
&PyDict
, including some optimised specializations on nightly.