rougier / from-python-to-numpy

An open-access book on numpy vectorization techniques, Nicolas P. Rougier, 2017
http://www.labri.fr/perso/nrougier/from-python-to-numpy
Other
2.06k stars 340 forks source link

Confusing "if 0" statement #71

Closed Motor-taxi-master-rider closed 6 years ago

Motor-taxi-master-rider commented 6 years ago

https://github.com/rougier/from-python-to-numpy/blob/1946c83e6f2b466688239adaa63c9c60d5aa6379/code/boid_numpy.py#L194

This line of script made me confusing. Does "if 0" means below block of code will never be executed?

rougier commented 6 years ago

Exactly. It's a very cheap "option". If you replace 0 with 1, you'll see the code executed.

Motor-taxi-master-rider commented 6 years ago

Thanks for your kind explanation.