Stewori / pytypes

Typing-toolbox for Python 3 _and_ 2.7 w.r.t. PEP 484.
Apache License 2.0
200 stars 20 forks source link

difference in is_subtype vs subclass for int and float #26

Open mariusvniekerk opened 6 years ago

mariusvniekerk commented 6 years ago

Is this intended behavior?

#Python 3.6.2 | packaged by conda-forge | (default, Jul 23 2017, 23:01:38)
#Type 'copyright', 'credits' or 'license' for more information
#IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pytypes

In [2]: issubclass(int, float)
Out[2]: False

In [3]: pytypes.is_subtype(int, float)
Out[3]: True
mariusvniekerk commented 6 years ago

nm saw this is part of the numeric tower stuff. It might be worth explicity calling it out somewhere in the readme.

Stewori commented 6 years ago

Yes that is numeric tower according to PEP484. Same with float and complex. You can turn it off via pytypes.apply_numeric_tower = False.