Mirroring what can be done (more efficiently) in numpy. For example:
>>> a = Array('float32', [10.0, 0.0, -3.0])
>>> a *= 2
>>> a
Array('float32', [20.0, 0.0, -6.0])
This should work for +, -, /, *. Note that + means something already when an iterable is being added but that shouldn't be confusing here. Oh, and we can also do >> and <<.
Not all formats and operation combinations will make sense. I think they're all OK for integers, and all except the shifts work for floats. I'd suggest not allowing any to work for hex, oct or bin formats.
How about logical operations? This would set the first bit of each item:
>>> a |= '0x80000000'
>>> a
Array('float32', [-20.0, 0.0, -6.0])
Should be easy to code if we're not too worried about efficiency for now.
Mirroring what can be done (more efficiently) in numpy. For example:
This should work for
+
,-
,/
,*
. Note that+
means something already when an iterable is being added but that shouldn't be confusing here. Oh, and we can also do>>
and<<
.Not all formats and operation combinations will make sense. I think they're all OK for integers, and all except the shifts work for floats. I'd suggest not allowing any to work for
hex
,oct
orbin
formats.How about logical operations? This would set the first bit of each item:
Should be easy to code if we're not too worried about efficiency for now.