On Monday, November 20, 2017 at 3:17:49 PM UTC-5, Chris Angelico wrote:
> Neither is perfect. You have to take your pick between them.
Right on, thanks for weighing in, Chris. Your responses have been very helpful.
I wouldn't feel comfortable claiming the authority to make this call alone. But
On Monday, November 20, 2017 at 2:31:40 PM UTC-5, MRAB wrote:
> What if there are duplicate elements?
>
> Should that be MyColl(some_elements) == MyOrderedColl(other_elements)
> iff len(some_elements) == len(other_elements) and set(some_elements) ==
> set(other_elements)?
Yes, that's what I
On Monday, November 20, 2017 at 1:55:26 PM UTC-5, Chris Angelico wrote:
> But what you have is the strangeness of non-transitive equality, which
> is likely to cause problems.
But this is exactly how Python's built-in dict and OrderedDict behave:
>>> od = OrderedDict([(1, 0), (2, 0), (3, 0)])
Suppose we're implementing an immutable collection type that comes in unordered
and ordered flavors. Let's call them MyColl and MyOrderedColl.
We implement __eq__ such that MyColl(some_elements) ==
MyOrderedColl(other_elements) iff set(some_elements) == set(other_elements).
But
My package, available at https://github.com/jab/bidict, is currently laid out
like this:
bidict/
├── __init__.py
├── _bidict.py
├── _common.py
├── _frozen.py
├── _loose.py
├── _named.py
├── _ordered.py
├── compat.py
├── util.py
I'd like to get some more feedback on a question about this layout