[Python-Dev] Re: The order of operands in the comparison

2019-07-22 Thread Serhiy Storchaka
22.07.19 11:04, Kyle Stanley пише: Serhiy Storchaka wrote: Thank you. The majority of the code uses needle on the right. There are just 6 places where it is on the left, and the half of them look copy-pasted, and in one place the C code differs from the corresponding Python implementation. There

[Python-Dev] Re: The order of operands in the comparison

2019-07-22 Thread Kyle Stanley
Serhiy Storchaka wrote: > Thank you. The majority of the code uses needle on the right. There are > just 6 places where it is on the left, and the half of them look > copy-pasted, and in one place the C code differs from the corresponding > Python implementation. There is an order more places wh

[Python-Dev] Re: The order of operands in the comparison

2019-07-22 Thread Serhiy Storchaka
20.07.19 18:26, Guido van Rossum пише: In an ideal world, needle is on the right. Let's replace needle with a constant: which of the following looks more natural?   for x in sequence:   if x == 5: return True or   for x in sequence:   if 5 == x: return True For me, 'x == 5' wins

[Python-Dev] Re: The order of operands in the comparison

2019-07-21 Thread raymond . hettinger
FWIW, the bisect_left and bisect_right functions have different argument order so that they can both use __lt__, making them consistent with sorting and with the heapq functions. Raymond ___ Python-Dev mailing list -- python-dev@python.org To unsubscri

[Python-Dev] Re: The order of operands in the comparison

2019-07-21 Thread Grant Jenks
There's also bisect_left and bisect_right which each do different things. The bisect_left function puts the needle on the right while the bisect_right function puts the needle on the left. I've thought a bit about these scenarios as the author of Sorted Containers but no user has ever raised an is

[Python-Dev] Re: The order of operands in the comparison

2019-07-20 Thread Guido van Rossum
In an ideal world, needle is on the right. Let's replace needle with a constant: which of the following looks more natural? for x in sequence: if x == 5: return True or for x in sequence: if 5 == x: return True For me, 'x == 5' wins with a huge margin. (There is a subculture of