[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Inada Naoki
On Fri, Dec 20, 2019 at 4:15 PM Wes Turner wrote: > > How slow and space-inefficient would it be to just implement the set methods > on top of dict? Speed: Dict doesn't cache the position of the first item. Calling next(iter(D)) repeatedly is O(N) in worst case. Space: It waste 8bytes per

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Wes Turner
How slow and space-inefficient would it be to just implement the set methods on top of dict? Do dicts lose insertion order when a key is deleted? AFAIU, OrderedDict do not lose insertion order on delete. Would this limit the utility of an ordered set as a queue? What set methods does a queue need

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[Nick] > I must admit that I was assuming without stating that a full OrderedSet > implementation would support the MutableSequence interface. Efficient access via index position too would be an enormous new requirement, My bet: basic operations would need to change from O(1) to O(log(N)).

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Nick Coghlan
On Fri., 20 Dec. 2019, 1:56 pm Tim Peters, wrote: > So what problem(s) would a dynamic ordered set really be aiming at? I > don't know. Consistency & predictability I understand and appreciate, > but little beyond that. Even FIFO ordering is somewhat a PITA, since > `next(iter(set))` is an

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[David Mertz ] > It's not obvious to me that insertion order is even the most obvious or > most commonly relevant sort order. I'm sure it is for Larry's program, but > often a work queue might want some other order. Very often queues > might instead, for example, have a priority number assigned

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[Nick] > I took Larry's request a slightly different way: Sorry, I was unclear: by "use case" I had in mind what appeared to me to be the overwhelming thrust of the _entirety_ of this thread so far, not Larry's original request. > he has a use case where he wants order preservation (so built in

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread David Mertz
On Thu, Dec 19, 2019 at 5:39 PM Nick Coghlan wrote: > I took Larry's request a slightly different way: he has a use case where > he wants order preservation (so built in sets aren't good), but combined > with low cost duplicate identification and elimination and removal of > arbitrary elements

[Python-Dev] Re: Thread argument for exc_info and public API

2019-12-19 Thread Victor Stinner
Hi, Le mer. 18 déc. 2019 à 16:43, Julien Danjou a écrit : > The only way to retrieve the current exception is via sys.excinfo or > PyErr_GetExcInfo in C. However, the issue is that they don't take a > PyThreadState as argument, but use _PyThreadState_GET() to retrieve the > thread state. If we

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Nick Coghlan
On Fri., 20 Dec. 2019, 2:58 am Tim Peters, wrote: > [Nick Coghlan ] > > Starting with "collections.OrderedSet" seems like a reasonable idea, > > though - that way "like a built-in set, but insertion order preserving" > will > > have an obvious and readily available answer, and it should also > >

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Wes Turner
OrderedSet implementations: - https://github.com/methane/cpython/pull/23/files - https://pypi.org/search/?q=orderedset - https://pypi.org/project/orderedset/ - https://code.activestate.com/recipes/576694/ - https://pypi.org/project/ordered-set/ -

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[Nick Coghlan ] > Starting with "collections.OrderedSet" seems like a reasonable idea, > though - that way "like a built-in set, but insertion order preserving" will > have an obvious and readily available answer, and it should also > make performance comparisons easier. Ya, I suggested starting

[Python-Dev] [RELEASE] Python 3.8.1, 3.7.6, 3.6.10, and 3.9.0a2 are now available!

2019-12-19 Thread Łukasz Langa
from locale import seasons_greetings seasons_greetings() On behalf of the entire Python development community, and the currently serving Python release team in particular, I'm pleased to announce the unprecedented combined release of no less than four versions of Python. Let's dig in! Python