[Python-ideas] Add a generic object comparison utility

2019-09-25 Thread Sébastien Eskenaz
Hello, Several libraries have complex objects but no comparison operators for them other than "is" which checks if we are comparing an object with itself. It would be quite nice to be able to compare any two objects together. I made this function in python to have a starting point https://gist.gi

[Python-ideas] Re: Set operations with Lists

2019-09-25 Thread Kyle Lahnakoski
On 2019-09-20 9:52 p.m., Richard Higginbotham wrote: Andrew Barnert wrote: set(b).intersection(a) or set(a) & set(b) or sb = set(b) then [x for x in a if x in sb] and you’re done. They can easily understand why it works. If they want to know why it’s faster, you can easily explain it, and they

[Python-ideas] Re: Set operations with Lists

2019-09-25 Thread Richard Higginbotham
Kyle Lahnakoski wrote: > On 2019-09-20 9:52 p.m., Richard Higginbotham wrote: > > Andrew Barnert wrote: > > set(b).intersection(a) or set(a) & set(b) or > > sb = > > set(b) then [x for x in a if x in sb] and you’re done. They can easily > > understand why it works. If they want to know why it’s fas

[Python-ideas] Re: Link: Bidirectional Aliasing in Python

2019-09-25 Thread Nutchanon Ninyawee
Nutchanon Ninyawee wrote: > Hi, Python community > I would like to discuss with you about the idea of "bidirectional Aliasing". > I am not good at English wording. I will try my best to communicate the idea > Link is a language feature that allows multiple variable names to always > refer to the >

[Python-ideas] Re: Add a generic object comparison utility

2019-09-25 Thread Steven D'Aprano
Hi Sébastien, and welcome. On Wed, Sep 25, 2019 at 04:15:58PM +0700, Sébastien Eskenaz wrote: > Hello, > > Several libraries have complex objects but no comparison operators for them > other than "is" which checks if we are comparing an object with itself. Not true: equality ``==`` is also defin

[Python-ideas] Add a time-based synchronization primitive

2019-09-25 Thread Viktor Roytman
The asyncio and threading modules include a number of synchronization primitives. In particular, a Semaphore allows you to limit the number of concurrent tasks if you need to stay under some capacity constraint. However, none of the existing primitives provide for rate limiting, as in making su

[Python-ideas] Re: Add a time-based synchronization primitive

2019-09-25 Thread Ilya Kulakov
Complement to the proposed idea. Some time ago I thought how cool it would be if one could implement a custom scheduler for Python's asyncio that used runtime metrics (defined by the user) to dynamically adjust priorities (with respect to the defined execution order). E.g. if the developer prior

[Python-ideas] Re: Add a generic object comparison utility

2019-09-25 Thread Andrew Barnert via Python-ideas
On Sep 25, 2019, at 02:15, Sébastien Eskenaz wrote: > > Hello, > > Several libraries have complex objects but no comparison operators for them > other than "is" which checks if we are comparing an object with itself. Most of them also have == which does the same comparison, because you get tha