Consistent default integer and floating-point types
See original GitHub issueIn today’s call we discussed that the current Array API standard does not regulate the default integer and floating-point types across all implementations, only that each implementation should pick one, document clearly and stick to it. However, this is not strong enough, as there could be cross-platform/portability issues.
For example, NumPy is inconsistent in handling the Python integers between Windows and Linux:
import numpy as np
a = np.arange(10, dtype=int)
a.dtype # np.int32 on Windows, np.int64 on Linux
Similar issues can be found in other APIs.
It’s worth noting that as pointed out by @kgryte, the standard does not permit passing dtype=int
to most of the functions, so this could eliminate a large class of such inconsistencies. But it’s still good to be explicit in the standard to ensure portability.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Constant and Literal Data Types - Visual Basic
A numeric integer literal is cast by default to the Integer data type. The default data type for floating-point numbers is Double ,...
Read more >Data Types and Sizes
D provides fundamental data types for integers and floating-point constants. Arithmetic may only be performed on integers in D programs.
Read more >Integers and Floating-Point Numbers - Julia Documentation
The default type for an integer literal depends on whether the target system has a 32-bit architecture or a 64-bit architecture:
Read more >Data Types
System ID Address Range Max Rows Max Columns Max Characters Read/Write Data T...
C 000001 ‑ 999999 N/A N/A N/A R/W Discrete
AR1C 000001 ‑...
Read more >what are default integer values?
The type of integer literals given in base 10 is the first type in the following list in which their value can fit:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be addressed in gh-167. I did put in one exception for default integers: for 32-bit vs. 64-bit Python. It’s possible to avoid too of course, but it’d be a fairly large change for limited benefit. So “may vary” on 32-bit seems okay.
No, I think asarray(1) should definitely have an integer dtype. But which integer dtype should it be? All it says is “If
dtype
isNone
, the output array data type must be inferred from the data type(s) inobj
” which isn’t clear. To me it even leaves open the possibility of value-based casting, which I think we want to avoid.