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

Add π to the math module #103172

Open
JosephSBoyle opened this issue Apr 1, 2023 · 0 comments
Open

Add π to the math module #103172

JosephSBoyle opened this issue Apr 1, 2023 · 0 comments
Labels
type-feature A feature request or enhancement

Comments

@JosephSBoyle
Copy link
Contributor

Currently, the math module in CPython uses the identifier math.pi to represent the mathematical constant π. This breaks user expectations and violates the principle of least surprise.

To improve consistency and readability, I propose changing math.pi to math.π symbol throughout the module. The reasoning for this is threefold:

  1. This change will make the code more intuitive for mathematicians and scientists (at least 99%+ of python users) who are more used to seeing the π symbol, thus reducing cognitive load and allowing them to build more complicated research code.

  2. Python supports unicode characters such as π and we don't take advantage of this enough. We can use π, therefore we should.

  3. Nobody currently knows how to type π, if we make this change users will have to open the math module and copy and paste the variable name - which is a great way to increase the visibility of important module internals that users need to read.

Some would be tempted to create a math.pi alias to maintain backwards compatibility, but I think that would only encourage people to continue using the non-symbolic variable (bad), so I propose simply deleting math.pi entirely (users will get the hint!).

This is a pretty small change so I don't think a news entry is necessary, in fact I think not having a news entry would make this change a sort of cool Easter Egg that users can discover and enjoy!

Kind regards and happy April 1st,
Joe

@JosephSBoyle JosephSBoyle added the type-feature A feature request or enhancement label Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant