Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast Numbers on its own isinstance() #10

Closed
ragardner opened this issue Nov 9, 2017 · 2 comments
Closed

Fast Numbers on its own isinstance() #10

ragardner opened this issue Nov 9, 2017 · 2 comments

Comments

@ragardner
Copy link

ragardner commented Nov 9, 2017

I am not sure if it's worth looking into because when importing fastnumbers by simply stating: import fastnumbers An error does not occur, but...

This code causes an error (Python 3.63 windows 10 64bit):

from fastnumbers import *

x = 1

if isinstance(x,int):
    print ("it's an integer")

the error is:

if isinstance(x,int):
TypeError: isinstance() arg 2 must be a type or tuple of types

@SethMMorton
Copy link
Owner

SethMMorton commented Nov 9, 2017

This is a known issue. I tried to highlight this in the API:

Behaves identically to the built-in int except for the following:

  • Is implemented as a function, not a class, which means it cannot be sub-classed, and has no from_bytes classmethod.

I suppose I did not call out that isinstance would also not work. Do you think it would be worthwhile to make this more clear?

@ragardner
Copy link
Author

ragardner commented Nov 9, 2017

Ah yeah, I should have spent more time reading the guide as opposed to skimming through it, sorry, it's clear to me now why isinstance() wouldn't work with the drop in int().

For people new to programming they might not know, but I guess if you have any knowledge of classes it's quite clear.

I was also previously unaware that import fastnumbers did not import the drop in replacements, I think this is the right behavior though as people might not want them especially when they already have access to the fast conversions etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants