8000 Add additional notes on longlong and Decimal(repr(scalar)) · numpy/numpy@f36efef · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f36efef

Browse files
committed
Add additional notes on longlong and Decimal(repr(scalar))
1 parent 7912d35 commit f36efef

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

doc/neps/nep-0051-scalar-representation.rst

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ with the new scheme to use the ``np`` prefix consistently:
5252
The NEP does not propose to change how these scalars print – only
5353
their representation (``__repr__``) will be changed.
5454
Further, array representation will not be affected since it already
55-
includes the ``dtype=`` when necessary.
55+
includes the ``dtype=`` when necessary.
5656

57-
The main motivation behind the change is that the Python numerical types
57+
The main motivation behind the change is that the Python numerical types
5858
behave differently from the NumPy scalars.
5959
For example numbers with lower precision (e.g. ``uint8`` or ``float16``)
6060
should be used with care and users should be aware when they are working
@@ -136,7 +136,7 @@ This NEP proposes to change the represenatation for NumPy scalars to:
136136
``np.longdouble('3.0')``. This ensures that it can always roundtrip correctly
137137
and matches ``decimal.Decimal``.
138138
Further, for these two the size based name such as ``float128`` will not
139-
be adopted, as it is platform dependend and imprecise.
139+
be adopted, as it is platform dependend and imprecise.
140140
* ``np.str_("string")`` and ``np.bytes_(b"byte_string")`` for string dtypes.
141141

142142
Where booleans are printed as their singletons since this is more concise.
@@ -164,6 +164,24 @@ to always print as ``longdouble`` and never ``float128`` or ``float96``.
164164
It does not include deprecating the ``np.float128`` alias.
165165
However, such a deprecation may occur independently of the NEP.
166166

167+
Integer scalar type name and instance represenatation
168+
-----------------------------------------------------
169+
170+
One detail is that due to NumPy scalar types being based on the C types,
171+
NumPy sometimes distinguishes them, for example on most 64 bit systems
172+
(not windows)::
173+
174+
>>> np.longlong
175+
numpy.longlong
176+
>>> np.longlong(3)
177+
np.int64(3)
178+
179+
The proposal will lead to the ``longlong`` name for the type while
180+
using the ``int64`` form for the scalar.
181+
This choice is made since ``int64`` is generally the more useful
182+
information for users, but the type name itself must be precise.
183+
184+
167185
Related Work
168186
============
169187

0 commit comments

Comments
 (0)
0