[issue21644] Optimize bytearray(int) constructor to use calloc()
Antoine Pitrou
report at bugs.python.org
Tue Jun 3 11:08:10 CEST 2014
Antoine Pitrou added the comment:
Responding to a comment in issue21233:
> Before:
> =======
> >>> x = bytearray(0)
> >>> m = memoryview(x)
> >>> x.__init__(10)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> BufferError: Existing exports of data: object cannot be re-sized
I don't think such use cases are supported. Generally, reinitializing an
object by calling __init__() explicitly is not well-defined, except when
advertised explicitly in the documentation. The only property we should
guarantee here is that it doesn't lead to an inconsistent object state, or to
hard crashes. Raising an exception is fine, and changing the raised
exception to another one should be fine as well.
----------
nosy: +pitrou
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21644>
_______________________________________
More information about the Python-bugs-list
mailing list