[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

Thanks, for the replies, didn't know about that.

Interesting thing that `collections.abc.Set` base class has implementations of 
`__and__`, `__or__`, `__sub__` and `__xor__` methods, it also provide 
`_from_iterable` class method that is used to create `Set` instance from 
iterable (all of those operators use this method).
```
class Set(Collection):
...
@classmethod
def _from_iterable(cls, it):
'''Construct an instance of the class from any iterable input.

Must override this method if the class constructor signature
does not accept an iterable for an input.
'''
return cls(it)
```

Basically, my proposition was to do smth similar to `collections.abc.Mapping`, 
but I understand your motivation not to implement this feature.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Brandt Bucher


Brandt Bucher  added the comment:

(Also, it would break virtual subclasses.)

--
nosy: +brandtbucher

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

This was discussed during the PEP review and rejected. The main reason is that 
this operator would need to create a new instance, and there is no standard API 
that's part of the Mapping protocol that can be used (the constructor of a 
Mapping instance might have unknown parameters).

--
nosy: +gvanrossum
resolution:  -> wont fix
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
keywords: +patch
pull_requests: +22970
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24141

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
components: +Library (Lib)
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping

2021-01-06 Thread Yurii Karabas


New submission from Yurii Karabas <1998uri...@gmail.com>:

In python3.9 `dict` `bitwise or` operator was introduced.

I think it will be great if `collections.abc.Mapping` and 
`collections.abc.MutableMapping` will have a default implementation of `bitwise 
or` operator.

--
messages: 384507
nosy: uriyyo
priority: normal
severity: normal
status: open
title: Add bitwise or operator to collections.abc Mapping and MutableMapping

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com