当操作数增加时,numpy'=='会切换语义

Pau*_*zer 7 python numpy equals operators numpy-broadcasting

只是偶然发现了以下情况:

Python 3.6.0 (default, Jan  9 2017, 22:01:27) 
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> 
>>> np.version.version
'1.14.2'
>>> 
>>> a = np.ones((100,), np.uint8)
>>> (a[:, None] == a).shape
(100, 100)
>>> a = np.ones((10000,), np.uint8)
>>> (a[:, None] == a).shape
(10000, 10000)
Run Code Online (Sandbox Code Playgroud)

到目前为止如此预期,但现在:

>>> a = np.ones((1000000,), np.uint8)
>>> (a[:, None] == a).shape
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'bool' object has no attribute 'shape'
Run Code Online (Sandbox Code Playgroud)

事实上:

>>> a[:, None] == a
False
Run Code Online (Sandbox Code Playgroud)

任何人都可以重现这个吗?这是一个bug还是某种功能?如果某个功能被记录在某个地方?

其他运算符只会引发内存错误

>>> a[:, None] | a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError
Run Code Online (Sandbox Code Playgroud)

在我看来这更有意义.