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

SUGGESTION: New Datatypes #70092

Closed
DevynJohnson mannequin opened this issue Dec 18, 2015 · 2 comments
Closed

SUGGESTION: New Datatypes #70092

DevynJohnson mannequin opened this issue Dec 18, 2015 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@DevynJohnson
Copy link
Mannequin

DevynJohnson mannequin commented Dec 18, 2015

BPO 25904
Nosy @mdickinson

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2015-12-18.14:12:31.992>
created_at = <Date 2015-12-18.12:23:27.434>
labels = ['interpreter-core', 'type-bug']
title = 'SUGGESTION: New Datatypes'
updated_at = <Date 2015-12-18.14:12:31.991>
user = 'https://bugs.python.org/DevynJohnson'

bugs.python.org fields:

activity = <Date 2015-12-18.14:12:31.991>
actor = 'mark.dickinson'
assignee = 'none'
closed = True
closed_date = <Date 2015-12-18.14:12:31.992>
closer = 'mark.dickinson'
components = ['Interpreter Core']
creation = <Date 2015-12-18.12:23:27.434>
creator = 'Devyn Johnson'
dependencies = []
files = []
hgrepos = []
issue_num = 25904
keywords = []
message_count = 2.0
messages = ['256678', '256682']
nosy_count = 2.0
nosy_names = ['mark.dickinson', 'Devyn Johnson']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue25904'
versions = ['Python 3.6']

@DevynJohnson
Copy link
Mannequin Author

DevynJohnson mannequin commented Dec 18, 2015

As we all know, Python is sometimes used to computer large numbers and precise numbers (i.e. doubles) with the help of third-party modules. In my opinion, it seems that Python may benefit from gaining new data-types such as "longint" (a "long long" in C) and "quad" (a "long double" in C). Thus, Python could natively be used for processing larger numbers than Python3.6.

@DevynJohnson DevynJohnson mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Dec 18, 2015
@mdickinson
Copy link
Member

Are you aware that Python's int type is already effectively arbitrary precision?

>>> 23**100
14886191506363039393791556586559754231987119653801368686576988209222433278539331352152390143277346804233476592179447310859520222529876001
>>> type(23**100)
<class 'int'>

For the suggestion of "quad": this has come up a couple of times in the past, but there are many things that would need to be discussed:

  • Is it actually useful or necessary?
  • Is it useful enough to warrant being included in the standard library, rather than provided by 3rd party libraries (gmpy, mpmath, ...).
  • Would it be better to provide an arbitrary-precision binary floating-point type? What would this provide that the existing arbitrary-precision decimal floating-point type (in the decimal module) doesn't already provide.
  • What would the impact be on the rest of the core code and the standard library: how many modules would need to be adapted to work with the new floating-point type, and how much work would that be?
  • What would the format be? You suggest matching "long double" in C, but that may not be the best plan: long double isn't consistent across even mainstream platforms. On Windows it's just the same as "double"; on OS X and most (all?) flavours of Linux it's the ancient x87 80-bit format. On some PPC machines it's a double-double format. IMO, the only sane format for something called "quad" would be the IEEE 754 standard binary128 format, but there's almost no hardware support for that format (excluding IBM zSeries). So we'd have to maintain (or borrow) a software implementation, which would be a *lot* of work. (I don't know of good free non-GPL implementations already in existence.)

I'm personally a strong -1 on adding a quad type to the Python core language: I don't think the extra complication is worth it. But if you want to take this further, I'd suggest taking it to the python-ideas mailing list: https://mail.python.org/mailman/listinfo/python-ideas.
I'm going to close the issue here: adding quad is too big a proposed change for a tracker issue; I'm sure lots of people would weigh in on a python-ideas discussion.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant