GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — bpo-37229: Add compare_function to bisect functions by FortStatement · Pull Request #13970 · python/cpython Conversation
|
|
Please fix bpo number |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d2f526e to
056e27a
Compare
There was an error while loading. Please reload this page.
|
Hi @GPery, thanks for taking the time to improve Python! As @tirkarthi mentionned, #11781 is already open to add this functionnality thought. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
#11781 adds a key parameter, which I believe is inferior. It's a specific case of a comparison callback, and in my use case would force me to create another class to serve as a comparator for my objects, at which point I might as well wrap them and add lt. Furthermore, I believe this is more in-line with similar standard functions in other languages such as C++ (std::sort), Java (PriorityQueue) or Rust (slice.sort_by). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@GPery, both are actually two ways to describe the same behavior, do you know |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
You're right, both cases are about the same. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I feel it might be relevant to note that this isn't reverting to the old-style (C-style) comparison. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
list sort uses |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
"every compared pair" is also (up to) once per item. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
What's your point exactly? Even with custom keys, you still need to compare every compared pair with (Note: I do think that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jdemeyer IIRC at least for list sorting the point is that python-provided comparison function is usually much slower than built-in compare methods for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
OK, so the performance argument becomes "in certain use cases, using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@asvetlov I'm not sure what were the original concerns, but I checked this PR and the I think this is a rather fair comparison. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I just tried and had the opposite result, both with and without pydebug, I wonder what exactly might be doing that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hi there, why was this one closed? Was it superseded/WONTFIXED? This addition would be amazing, I keep hitting it. Let me know if there's any way I can help. Thanks to all. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.