[Numpy-discussion] Type of 1st argument in Numexpr where()

Ivan Vilata i Balaguer ivilata at carabos.com
Wed Dec 20 12:51:55 CST 2006


Tim Hochberg (el 2006-12-20 a les 09:20:01 -0700) va dir::

> Actually, this is on purpose. Numpy.where (and most other switching 
> constructs in Python) will switch on almost anything. In particular, any 
> number that is nonzero is considered True, zero is considered False. By 
> changing the signature, you're restricting where to only accepting 
> booleans. Since booleans and ints can by freely cast to doubles in 
> numexpr, always using float for the condition saves us a couple of opcodes.
> [...]

Yes, I understand the reasons you expose here.  Nou you brought the
topic about, I'm curious about what does "always using float for the
condition saves us a couple of opcodes" mean.  Could you explain this?
Just for curiosity. :)

::

	Ivan Vilata i Balaguer   >qo<   http://www.carabos.com/
	       Cárabos Coop. V.  V  V   Enjoy Data
	                          ""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 309 bytes
Desc: Digital signature
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061220/c8b47a55/attachment.bin 


More information about the Numpy-discussion mailing list