Skip to content

static typing #133

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

Open
jorenham opened this issue Apr 11, 2025 · 4 comments · May be fixed by #136
Open

static typing #133

jorenham opened this issue Apr 11, 2025 · 4 comments · May be fixed by #136
Assignees
Milestone

Comments

@jorenham
Copy link
Member

jorenham commented Apr 11, 2025

If there's any interest in it, I could write some stubs, or inline annotations. Or in case there won't be any new releases, the stubs could also be distributed as a stand-alone stubs-only package, or as part of https://github.com/numpy/numtype.

Either way, I don't mean to flex or anything, but once everything is set up, annotating this project would probably take me less than an hour to annotate, so let me know if that would be of any help.

@jorenham
Copy link
Member Author

I guess it still looks pretty active: https://pypistats.org/packages/numpy-financial

@Kai-Striega
Copy link
Member

I'd be keen on this, however I don't have much time to review it at the moment

@jorenham jorenham self-assigned this Apr 11, 2025
@jorenham
Copy link
Member Author

jorenham commented Apr 11, 2025

How attached to startup time are you? Importing typing can already add ~25ms, depending on the Python version that's used. I'll also need to use @typing.overload quite a bit, which isn't free.

If that's a problem, then I'll go for .pyi stubs (2 to be exact), which have 0 runtime impact. The disadvantage of stubs are the additional maintenance burden, and the lack of support for runtime type-checkers like beartype. But on the other hand, stubs are a bit more flexible than inline annotations, especially in case of function @overloading, which I expect to use for almost every function in _financial.py.

@jorenham jorenham changed the title stubs, maybe? static typing Apr 11, 2025
@Kai-Striega
Copy link
Member

As far as I know, of the code I've seen that use numpy-financial, it isn't used in performance critical code. So I'm not too attached to an additional ~25ms and would much rather optimize for maintainability.

@Kai-Striega Kai-Striega added this to the 2.0 milestone Apr 16, 2025
@jorenham jorenham linked a pull request Apr 20, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants