question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consistent default integer and floating-point types

See original GitHub issue

In 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:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rgommerscommented, Apr 20, 2021

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.

1reaction
asmeurercommented, Apr 2, 2021

No, I think asarray(1) should definitely have an integer dtype. But which integer dtype should it be? All it says is “If dtype is None, the output array data type must be inferred from the data type(s) in obj” which isn’t clear. To me it even leaves open the possibility of value-based casting, which I think we want to avoid.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found