[issue4356] Add "key" argument to "bisect" module functions

2021-10-04 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 7128864885340e0d75ddfe32887257e245d9c1f7 by Pablo Galindo (Miss Islington (bot)) in branch '3.10': bpo-4356: Mention the new key arguments for the bisect module APIs in the 3.10 What's new (GH-28339) (GH-28340)

[issue4356] Add "key" argument to "bisect" module functions

2021-09-14 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset dda5ff2d095c795f00afaa64505069a2409f6099 by Miss Islington (bot) in branch '3.10': bpo-4356: Mention the new key arguments for the bisect module APIs in the 3.10 What's new (GH-28339) (GH-28340)

[issue4356] Add "key" argument to "bisect" module functions

2021-09-14 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 21.0 -> 22.0 pull_requests: +26753 pull_request: https://github.com/python/cpython/pull/28340 ___ Python tracker

[issue4356] Add "key" argument to "bisect" module functions

2021-09-14 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 1aaa85949717e4ab2ed700e58762f0a3ce049a37 by Pablo Galindo Salgado in branch 'main': bpo-4356: Mention the new key arguments for the bisect module APIs in the 3.10 What's new (GH-28339)

[issue4356] Add "key" argument to "bisect" module functions

2021-09-14 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- nosy: +pablogsal nosy_count: 20.0 -> 21.0 pull_requests: +26752 pull_request: https://github.com/python/cpython/pull/28339 ___ Python tracker

[issue4356] Add "key" argument to "bisect" module functions

2020-10-19 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue4356] Add "key" argument to "bisect" module functions

2020-10-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 871934d4cf00687b3d1411c6e344af311646c1ae by Raymond Hettinger in branch 'master': bpo-4356: Add key function support to the bisect module (GH-20556) https://github.com/python/cpython/commit/871934d4cf00687b3d1411c6e344af311646c1ae

[issue4356] Add "key" argument to "bisect" module functions

2020-08-21 Thread Gregory P. Smith
Change by Gregory P. Smith : -- versions: +Python 3.10 -Python 3.9 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue4356] Add "key" argument to "bisect" module functions

2020-05-31 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: +19799 pull_request: https://github.com/python/cpython/pull/20556 ___ Python tracker ___

[issue4356] Add "key" argument to "bisect" module functions

2019-06-11 Thread Raymond Hettinger
Change by Raymond Hettinger : -- versions: -Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue4356] Add "key" argument to "bisect" module functions

2019-06-11 Thread G
G added the comment: I did, thanks! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue4356] Add "key" argument to "bisect" module functions

2019-06-11 Thread Mark Dickinson
Mark Dickinson added the comment: > I opened a relevant PR, https://github.com/python/cpython/pull/11781. Did you mean https://github.com/python/cpython/pull/13970 ? -- ___ Python tracker

[issue4356] Add "key" argument to "bisect" module functions

2019-06-11 Thread G
G added the comment: I opened a relevant PR, https://github.com/python/cpython/pull/11781. I believe a key parameter is inferior to a comparison callback. The former is a specific case of the latter, and in my use case would force me to create another class to serve as a comparator for my

[issue4356] Add "key" argument to "bisect" module functions

2019-05-26 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- versions: +Python 3.9 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue4356] Add "key" argument to "bisect" module functions

2019-05-26 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Can you not use functools.cmp_to_key() for this? Here's an example: >>> import bisect, functools >>> l = [('f', 5), ('d', 3), ('c', 2), ('b', 1), ('a', 0)] >>> def cmp(a, b): ... if a > b: return -1 ... if a < b: return 1 ... return 0 ... >>>

[issue4356] Add "key" argument to "bisect" module functions

2019-05-26 Thread Neil Girdhar
Neil Girdhar added the comment: The problem with `key=lambda item: -item` is that item cannot always be easily negated. For example, tuples are often used as keys. -- ___ Python tracker

[issue4356] Add "key" argument to "bisect" module functions

2019-05-26 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: I think it could be done with `key=lambda item: -item` if the key argument is added. -- ___ Python tracker ___

[issue4356] Add "key" argument to "bisect" module functions

2019-05-25 Thread Kevin G
Kevin G added the comment: Can anyone add "reverse" support? Key and reverse support are both functional requirement. -- nosy: +flyingosprey ___ Python tracker ___

[issue4356] Add "key" argument to "bisect" module functions

2019-03-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'll look at it this weekend. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue4356] Add "key" argument to "bisect" module functions

2019-03-12 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi, there has been renewed interest from @alexchamberlain and @f6v on GitHub for this feature. Would it be possible to get the patch reviewed so we can add it in 3.8? -- ___ Python tracker

[issue4356] Add "key" argument to "bisect" module functions

2019-02-18 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi everybody, I opened PR 11781 to add a key argument to functions in the bisect module. I agree with @dmtr's points that this addition is not a bad design. As far as I can tell, the key function is at called at most once per item as this example where an

[issue4356] Add "key" argument to "bisect" module functions

2019-02-07 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- nosy: +remi.lapeyre versions: +Python 3.8 -Python 3.7 ___ Python tracker ___ ___ Python-bugs-list mailing

[issue4356] Add "key" argument to "bisect" module functions

2019-02-07 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- pull_requests: +11764, 11765, 11766 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue4356] Add "key" argument to "bisect" module functions

2019-02-07 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- pull_requests: +11764 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue4356] Add "key" argument to "bisect" module functions

2019-02-07 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- pull_requests: +11764, 11765 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue4356] Add "key" argument to "bisect" module functions

2018-01-21 Thread Greg Lindahl
Change by Greg Lindahl : -- nosy: +wumpus ___ Python tracker ___ ___ Python-bugs-list

[issue4356] Add "key" argument to "bisect" module functions

2017-11-03 Thread Gregory P. Smith
Gregory P. Smith added the comment: obviously didn't make it in 3.6 but this still seems desirable. I just saw someone at work propose a trivial port of golang's sort.Search - https://golang.org/pkg/sort/#Search - in Python which caused me to hunt for an issue on bisect

[issue4356] Add "key" argument to "bisect" module functions

2016-02-29 Thread Neil Girdhar
Neil Girdhar added the comment: I'm also looking for bisect with a key argument (numpy array of records, want to search on one element). However, I don't see bisect in the what's new: https://docs.python.org/3.6/whatsnew/3.6.html ? Any luck with the implementation? -- nosy: +neil.g

[issue4356] Add key argument to bisect module functions

2015-08-18 Thread Yury Selivanov
Changes by Yury Selivanov yseliva...@gmail.com: -- nosy: +yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___ ___ Python-bugs-list

[issue4356] Add key argument to bisect module functions

2015-07-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'll add a key= variant for Python 3.6. -- versions: +Python 3.6 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2015-07-06 Thread Mark Dickinson
Mark Dickinson added the comment: I've just encountered another case where the lack of a key on bisect has led to more complicated and error-prone code than necessary. Quick summary: we've got a list containing an ordered collection of non-overlapping open intervals on the real line. (In

[issue4356] Add key argument to bisect module functions

2015-04-30 Thread Eric Reynolds
Eric Reynolds added the comment: In the meantime here is a workaround https://gist.github.com/ericremoreynolds/2d80300dabc70eebc790 -- nosy: +ericreynolds ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356

[issue4356] Add key argument to bisect module functions

2015-03-06 Thread Dmitry Chichkov
Dmitry Chichkov added the comment: Use case: a custom immutable array with a large number of items and indirect key field access. For example ctypes.array, memoryview or ctypes.pointer or any other custom container. 1. I'm not sure how anyone can consider a precached key array as a right ans

[issue4356] Add key argument to bisect module functions

2014-03-06 Thread Josh Rosenberg
Changes by Josh Rosenberg shadowran...@gmail.com: -- nosy: +ShadowRanger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___ ___

[issue4356] Add key argument to bisect module functions

2014-02-10 Thread Guido van Rossum
Changes by Guido van Rossum gu...@python.org: -- nosy: -gvanrossum ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___ ___ Python-bugs-list

[issue4356] Add key argument to bisect module functions

2014-01-13 Thread Dima Tisnek
Dima Tisnek added the comment: I've worked around this in 2.6/2.7 like this: class Arr: def __getitem__(self, i): return foo(i) # your key function def __len__(self): return 1000 # your max index value bisect.bisect(Arr(), value, ...) -- nosy:

[issue4356] Add key argument to bisect module functions

2012-09-12 Thread Terry J. Reedy
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___ ___

[issue4356] Add key argument to bisect module functions

2012-02-09 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: On python-ideas, thread Optional key to `bisect`'s functions? Guido wrote Bingo. That clinches it. We need to add key=. 'That' being the fact that values that have keys may not be comparable themselves (in py3), so that comparing (key,value)

[issue4356] Add key argument to bisect module functions

2012-02-09 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: I'm +1 on adding this feature. See discussion in python-ideas. PS. It should also be added to heapq. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356

[issue4356] Add key argument to bisect module functions

2012-02-09 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: Already on tracker as #13742 Add a key parameter (like sorted) to heapq.merge -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2010-09-01 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Fixed in r84383. -- resolution: duplicate - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356

[issue4356] Add key argument to bisect module functions

2010-08-29 Thread Sean Reifschneider
Sean Reifschneider j...@tummy.com added the comment: This issue came up on #python IRC, and that combined with the number of times this has been duplicated makes me think that maybe the mention of the SortedCollection recipe should be a little more prominent. Perhaps either moved up by the

[issue4356] Add key argument to bisect module functions

2010-08-29 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: maybe the mention of the SortedCollection recipe should be a little more prominent. Thanks for the suggestion. Will look at moving the note higher on the page. -- components: +Documentation -Library (Lib) status:

[issue4356] Add key argument to bisect module functions

2010-08-07 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Added a link to the a SortedCollections recipe, added example of how to do searches, and noted the O(n) performance of the insort() functions. See r83786 -- status: open - closed

[issue4356] Add key argument to bisect module functions

2010-04-16 Thread Alex
Alex alex.gay...@gmail.com added the comment: Looks nice to me, however I wonder if there isn't some overlap with the requests to add a key= kwarg to heapq methods (and the discussion about adding a Heap class there). -- nosy: +alex ___ Python

[issue4356] Add key argument to bisect module functions

2010-04-15 Thread Raymond Hettinger
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: Removed file: http://bugs.python.org/file16929/SortedCollection.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2010-04-15 Thread Raymond Hettinger
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: Added file: http://bugs.python.org/file16944/SortedCollection.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2010-04-14 Thread Brian Scearce
Brian Scearce b...@pathetique.com added the comment: This was closed over a year ago, but since mark.dickinson was asking for convincing use-cases: I'm breaking up a file into line-delimited chunks. These chunks are non-overlapping, contiguous, and tend to be fairly large, so I'm just

[issue4356] Add key argument to bisect module functions

2010-04-14 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I'll take another look at this one. -- status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2010-04-14 Thread Brian Scearce
Brian Scearce b...@pathetique.com added the comment: For what it's worth, after I posted my comment, I realized I could use tuple comparison semantics: loc = bisect.bisect(mapping, (line,)) since my key happens to be at index 0. key= would still be nice. --

[issue4356] Add key argument to bisect module functions

2010-04-14 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: What would you guys think about adding a class that uses bisect internally so that the keyfunc() never gets called more than once per key? This could be added to the docs as a cut-and-pastable recipe or it could be added to

[issue4356] Add key argument to bisect module functions

2010-04-14 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Attaching a draft of a sorted collection class. Any comments? -- Added file: http://bugs.python.org/file16929/SortedCollection.py ___ Python tracker rep...@bugs.python.org

[issue4356] Add key argument to bisect module functions

2009-11-02 Thread Milko Krachounov
Milko Krachounov pyt...@milko.3mhz.net added the comment: I've been bugged by the lack of key= argument for bisect for some time now, and today I got to read this and the previous issues about the matter. I still fail to understand the reasons for the rejections. It might encourage bad design in

[issue4356] Add key argument to bisect module functions

2009-11-02 Thread Milko Krachounov
Changes by Milko Krachounov pyt...@milko.3mhz.net: Added file: http://bugs.python.org/file15249/bisect-py3k.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2009-11-02 Thread Milko Krachounov
Changes by Milko Krachounov pyt...@milko.3mhz.net: Added file: http://bugs.python.org/file15250/bench_bisect_key.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2009-11-02 Thread Raymond Hettinger
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: -- assignee: - rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2008-11-21 Thread Miki Tebeka
Miki Tebeka [EMAIL PROTECTED] added the comment: I agree you can get around this with defining __cmp__, however same goes to sort and it was added anyway. My take on it is that sometimes I need to find something in a big list of objects, and I don't like to do DSU and not add __cmp__ to the

[issue4356] Add key argument to bisect module functions

2008-11-21 Thread Terry J. Reedy
Terry J. Reedy [EMAIL PROTECTED] added the comment: Just a reminder that __cmp__ is gone in 3.0. I presume bisect, like sort, only requires __lt__ and perhaps __eq__, though I can find no doc of either. -- nosy: +tjreedy ___ Python tracker [EMAIL

[issue4356] Add key argument to bisect module functions

2008-11-20 Thread Mark Dickinson
Mark Dickinson [EMAIL PROTECTED] added the comment: What about cases where performance is unimportant, or where the key function is fast (e.g. an attribute access)? Then something like bisect(a, x, key=attrgetter('size')) is easy to write and read. Mightn't this be considered good design,

[issue4356] Add key argument to bisect module functions

2008-11-20 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: I had said almost always. Sure, if you don't care about performance or scalability, a key= argument would be a net win. We're responsible for creating an API that steers most programmers in the right direction (Tim sez we read Knuth so you

[issue4356] Add key argument to bisect module functions

2008-11-20 Thread Raymond Hettinger
Changes by Raymond Hettinger [EMAIL PROTECTED]: -- resolution: - duplicate status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2008-11-20 Thread Mark Dickinson
Mark Dickinson [EMAIL PROTECTED] added the comment: One case I've been thinking about is that of maintaining a list of Decimal objects that are sorted by absolute value. For this, having to create a list of (abs(x), x) pairs just seems clumsy compared to using a key argument to bisect.

[issue4356] Add key argument to bisect module functions

2008-11-19 Thread Miki Tebeka
New submission from Miki Tebeka [EMAIL PROTECTED]: It'd be helpful of the functions in the bisect modules will have a key argument just like sort. -- messages: 76060 nosy: tebeka severity: normal status: open title: Add key argument to bisect module functions

[issue4356] Add key argument to bisect module functions

2008-11-19 Thread Miki Tebeka
Changes by Miki Tebeka [EMAIL PROTECTED]: -- components: +Library (Lib) type: - feature request versions: +Python 2.7, Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4356 ___

[issue4356] Add key argument to bisect module functions

2008-11-19 Thread Mark Dickinson
Mark Dickinson [EMAIL PROTECTED] added the comment: This request has come up repeatedly (and been rejected) in the past. See issues 2954, 3374, 1185383, 1462228, 1451588, 1619060. Could you perhaps explain your particular use case for this? A few truly convincing use-cases might increase

[issue4356] Add key argument to bisect module functions

2008-11-19 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: Miki, the issue is that bisect calls tend to be made repeatedly, so the key function can be called over and over again for the same argument. It is almost always a better design to simply decorate the list so the key function never gets