Re: [Python-Dev] threading.Semaphore()'s counter can become negative for non-ints

2012-01-31 Thread T.B.
I concur. This is very much a non-problem. There is no need to add more code and slow running time with superfluous type checks. Raymond What do you think about the following check from threading.py: @@ -317,8 +317,6 @@ self._value = value def acquire(self, blocking=True, time

Re: [Python-Dev] threading.Semaphore()'s counter can become negative for non-ints

2012-01-31 Thread T.B.
On 2012-01-31 00:23, Benjamin Peterson wrote: 2012/1/30 Nick Coghlan: On Tue, Jan 31, 2012 at 8:11 AM, Matt Joiner wrote: It's also potentially lossy if you incremented and decremented until integer precision is lost. My vote is for an int type check. No casting. operator.index() is built fo

Re: [Python-Dev] threading.Semaphore()'s counter can become negative for non-ints

2012-01-30 Thread T.B.
On 2012-01-30 20:52, Guido van Rossum wrote: TB, what's your use case for passing a float to a semaphore? Semaphores are conceptually tied to integers. You've kept arguing a few times now that the workaround you need are clumsy, but you've not explained why you're passing floats in the first plac

Re: [Python-Dev] threading.Semaphore()'s counter can become negative for non-ints

2012-01-30 Thread T.B.
On 2012-01-30 01:46, Victor Stinner wrote: But why would you want to pass a float? It seems like API abuse to me. If something should be changed, Semaphore(arg) should raise a TypeError if arg is not an integer. Short version: I propose the the change to be -while self._value == 0:

[Python-Dev] threading.Semaphore()'s counter can become negative for non-ints

2012-01-28 Thread T.B.
Hello python-dev, This is probably worth of a bug report: While looking at threading.py I noticed that Semaphore's counter can go below zero. This is opposed to the docs: "The counter can never go below zero; ...". Just try: import threading s = threading.Semaphore(0.5) # You can now acquire