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

reimplement sqrt and isqrt in pure vyper and remove them from builtins #4515

Open
cyberthirst opened this issue Mar 12, 2025 · 2 comments
Open
Labels
release - must release blocker
Milestone

Comments

@cyberthirst
Copy link
Collaborator

Simple Summary

Move sqrt and isqrt builtins to pure Vyper so that they're implementation is easier to verify and remove complexity from the compiler codebase.

Motivation

Builtins are a major source of complexity in the compiler codebase and have caused many codegen bugs in the past (for example, see: GHSA-5jrj-52x8-m64h). Pure Vyper is more accessible for general audience and thus has higher chance of being further audited.

Additionally, sqrt is implemented via a special inlining mechanism which imposes the need to often handle it via special edge-cases (for example, see: #4219 (comment)).

Specification

We suggest making sqrt and isqrt pure library functions.

Backwards Compatibility

This is a breaking change, the builtins would have to be explicitly imported from the standard library.

@cyberthirst cyberthirst added the needs triage needs triage label Mar 12, 2025
@cyberthirst cyberthirst added this to the v0.4.2 milestone Mar 12, 2025
@charles-cooper
Copy link
Member

in terms of scoping, i would say we should start with sqrt() because of the inlining mechanism

@cyberthirst
Copy link
Collaborator Author

cyberthirst commented Mar 13, 2025

one thing we might have to deal with is selective imports. that would enable importing sqrt as a function(eg from stdlib.math import sqrt)
edit: updated example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release - must release blocker
Projects
None yet
Development

No branches or pull requests

2 participants