You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be clear, dtypes aren't intended to be singletons, and in general this
is fine for dictionaries and sets -- those require objects to be ==, not
'is'.
.
The weird behavior here is a more specific bug related to int64 and
longlong specifically, as @argriffing notes...
On Sep 9, 2015 1:42 PM, "argriffing" [email protected] wrote:
Just for reference, here's a longer comparison. I don't really understand how this works, and I'm not sure which parts of this (if any) are considered buggy. Also, I don't understand exactly how it is related to the issue I linked above. According to @jaimefrio in that thread, the issue seems to be that PyLong objects are always converted to NPY_LONGLONG, even when it is the same size as NPY_LONG but I'm not sure if this is the same issue causing confusion here, or even if that issue is the one that @njsmith had in mind when referring to a more specific bug related to int64 and longlong specifically.
Your conclusion about int64 and longlong (which are scalar types, not dtypes, btw) not being singletons is indeed not right.
As said before, what you're seeing here is that np.int64 and np.longlong are two different scalar types that have the same __repr__:
In [1]: np.int64 is np.longlong
Out[1]: False
In [2]: type(np.int64()) is type(np.longlong())
Out[2]: False
In [3]: np.int64(), np.longlong()
Out[3]: (np.int64(0), np.int64(0))
It's pretty confusing IMO, but doesn't really matter much in practice.
Activity
argriffing commentedon Sep 9, 2015
Is this a duplicate of #5801?
njsmith commentedon Sep 9, 2015
To be clear, dtypes aren't intended to be singletons, and in general this
is fine for dictionaries and sets -- those require objects to be ==, not
'is'.
.
The weird behavior here is a more specific bug related to int64 and
longlong specifically, as @argriffing notes...
On Sep 9, 2015 1:42 PM, "argriffing" [email protected] wrote:
argriffing commentedon Sep 9, 2015
Just for reference, here's a longer comparison. I don't really understand how this works, and I'm not sure which parts of this (if any) are considered buggy. Also, I don't understand exactly how it is related to the issue I linked above. According to @jaimefrio in that thread,
the issue seems to be that PyLong objects are always converted to NPY_LONGLONG, even when it is the same size as NPY_LONGbut I'm not sure if this is the same issue causing confusion here, or even if that issue is the one that @njsmith had in mind when referring toa more specific bug related to int64 and longlong specifically.jorenham commentedon Jul 22, 2026
Your conclusion about
int64andlonglong(which are scalar types, not dtypes, btw) not being singletons is indeed not right.As said before, what you're seeing here is that
np.int64andnp.longlongare two different scalar types that have the same__repr__:It's pretty confusing IMO, but doesn't really matter much in practice.