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

combine commands.LargeInt with commands.Range #787

Open
onerandomusername opened this issue Oct 3, 2022 · 2 comments · May be fixed by #1201
Open

combine commands.LargeInt with commands.Range #787

onerandomusername opened this issue Oct 3, 2022 · 2 comments · May be fixed by #1201
Labels
feature request Request for a new feature good first issue Good for newcomers
Milestone

Comments

@onerandomusername
Copy link
Member

onerandomusername commented Oct 3, 2022

Summary

LargeInt cannot be restricted like Range, and Range cannot be a big int.

What is the feature request for?

disnake.ext.commands

The Problem

LargeInt is an integer bigger than 2 ** 53, and Range only works on numbers below 2 ** 53. It would be nice to have a combination of the two, possibly even merge them into one class.

We also don't have LargeFloat right now, so a modified Range could potentially support that.

The Ideal Solution

Continue to keep LargeInt around, but merge support into Range. This means that if Range has more than the limit provided by discord, we instead use an underlying string type and manually compute the value. In order to constrain the value further, we should provide min_length and max_length computed to the length of the object.

For example:

# setup variables
# for those wondering, these are the shortest and current longest possible snowflake values
min = int("1" + "0" * 16)
max = int("9" * 19)


commands.Range[min, max] 

This would create a Range object that is rendered as a string but has a min_length set to 17, and a max_length set to 19, as that is how long the beginning number and second number are after converted to a string. After that we would compute the limitations as normal once we received an interaction. We should also keep in mind python/cpython#95778

The Current Solution

None

Additional Context

No response

@onerandomusername onerandomusername added the feature request Request for a new feature label Oct 3, 2022
@onerandomusername onerandomusername added this to the disnake v2.7 milestone Oct 3, 2022
@onerandomusername onerandomusername added the good first issue Good for newcomers label Oct 3, 2022
@EmreTech
Copy link
Contributor

EmreTech commented Nov 7, 2022

I would like to implement this!

@Enegg
Copy link
Contributor

Enegg commented May 30, 2024

Since #991 made commands.Range require taking the actual type as first param, I think making it take LargeInt would be a natural solution to this issue: commands.Range[LargeInt, min, max]
Exceeding the bounds on normal int should raise an error, telling the user to use LargeInt if they really want the greater range
This way it's an explicit opt-in to use a string type to represent larger numbers

@Enegg Enegg linked a pull request Jun 2, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature good first issue Good for newcomers
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

4 participants