Does it? [edit: yes, it does, but only from Python 3.15, see below]
>>> class Z:
... def __float__(self): return 1.234
...
>>> math.sin(Z())
0.9438182093746337
>>> time.sleep(float(Z()))
>>> time.sleep(Z())
Traceback (most recent call last):
File "<python-input-7>", line 1, in <module>
time.sleep(Z())
~~~~~~~~~~^^^
TypeError: 'Z' object cannot be interpreted as an integer
OTOH, sleep does convert to int implicitly:
>>> class Z:
... def __float__(self): return 1.234
... def __index__(self): return 42
... def __int__(self): return -42
...
>>> start=time.time(); time.sleep(Z()); end=time.time(); print(end-start)
42.00052738189697
So it seems (at least in Python 3.13):
sleepimplicitly converts toint(by__index__method)sleepneeds actualfloat(or subclass) for sub-second precision
I couldn’t find that in the documentation.
Perhaps typeshed should type sleep as def sleep(seconds: float | SupportsIndex, /) -> None: ... instead of def sleep(seconds: float, /) -> None: ...?
[edit 2: typeshed issue 15313]
Edit: for above, Python 3.14 resembles 3.13. But in Python 3.15 (current a5), sleep does support float:
Python 3.15.0a5 (tags/v3.15.0a5:d51cc01, Jan 14 2026, 15:09:24) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class Z:
... def __float__(self): return 1.234
...
>>> import time
>>> time.sleep(Z())
>>> exit