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

Optimizer: Expanding Union Types #402

Open
nielstron opened this issue Aug 23, 2024 · 0 comments
Open

Optimizer: Expanding Union Types #402

nielstron opened this issue Aug 23, 2024 · 0 comments
Labels
bb: medium Medium issue according to bug bounty categorization bug bounty This issue is prized out as part of the Bug Bounty Program enhancement New feature or request

Comments

@nielstron
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently functions have to decide between performance and generalizability. I.e. a function foo(Union[A, B]) that does internal isinstance checks to distinguish the two types has an inherently higher cost that writing manually foo_A(A) and foo_B(B). However this would lead to code duplication and more difficult mainenance.

Describe the solution you'd like
For any function foo that accepts union type arguments, we automatically generate foo_A and foo_B as described above. All calls to foo where the type of the argument is known at compilation time are remapped to foo_A and foo_B. Inside foo_A and foo_B a simple truth analysis + dead code analysis can remove the redundant isinstance checks. This is an O3 optimization and can come with significant increase in the script size.

Describe alternatives you've considered
None

Additional context
Would i.e. allow more performant Union[int, Fraction] add and mul implementations.

Bug bounty: 750 ADA

@nielstron nielstron added enhancement New feature or request bug bounty This issue is prized out as part of the Bug Bounty Program bb: medium Medium issue according to bug bounty categorization labels Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bb: medium Medium issue according to bug bounty categorization bug bounty This issue is prized out as part of the Bug Bounty Program enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant