Merlijn van Deen <valhall...@gmail.com> added the comment:

Although there is one use case which I now realise due to your post: easier 
1-on-1 implementation of existing algorithms.

Another possible reason to implement it is that it's not that hard to implement 
the sign() function wrongly, if it also has to work with nans. This 
implementation:

def signum(x):
    return (x > 0) - (x < 0)

returns 0 for nan, which is wrong (it should return nan). Another naive 
implementation

def signum(x):
    return math.copysign(1, x)

also fails for nan, and gives a result for +/- 0 that could be right or wrong, 
depending on context.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue829370>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to