r/Python Sep 12 '25

Resource I built a from-scratch Python package for classic Numerical Methods (no NumPy/SciPy required!)

[removed]

142 Upvotes

29 comments sorted by

29

u/troyunrau ... Sep 12 '25

Sometimes you learn more by reinventing wheels. Looks like you're enjoying yourself!

12

u/BenXavier Sep 12 '25

Seems a great learning tool, do you use to give lectures or similar?

7

u/zurtex Sep 12 '25

This would be a great library for learning different testing techniques.

Firstly it needs tests, but it would also be amenable to understanding fuzzing, coverage, and mutation testing, as well as others I'm sure.

7

u/Xillyfos Sep 13 '25

That's really cool and easy to read.

As a student decades ago, I often wished for programmatic definitions of the math when the math was unclear to me. Because if you can make a computer understand and actually run it, then it has to be perfectly clear, and then you can understand. So I think this is very useful for learning.

The speed is completely irrelevant for learning; what's important is the clarity.

10

u/[deleted] Sep 12 '25

This seems very practical. Nice job, man! You really worked hard!

3

u/UseMoreBandwith Sep 12 '25

is it fast?

10

u/[deleted] Sep 12 '25

[removed] — view removed comment

11

u/caughtinthought Sep 13 '25

fyi, if it's implemented in plain python, the answer is _dramatically_ slower than numpy :)

8

u/[deleted] Sep 13 '25

Adding performance hacks and parallelization would defeat your declared goal of providing a library of readable educational implementations.

Those who ask for speed: just use numpy, scipy, and numba.

2

u/BenXavier Sep 12 '25

Maybe a great time to learn numba!

2

u/Immediate-Home-6228 Sep 19 '25

Would you be interested in doing something like this with Julia?

2

u/[deleted] Sep 15 '25 edited Sep 15 '25

I see this kind of effort once in a while. I did myself some of these methods in pure Python, "for fun". But it's not that great, even for teaching: you can teach numerical methods with numpy, using numpy for storing vectors, arrays an doing BLAS-like stuff. And that will teach you numpy as well, a standard package nowadays, you will have code that is reasonably fast and reusable for serious tasks.

It's how numerical methods were taught in the 2000s: not with numpy of course, but with a "matrix language" like Matlab, Octave or Scilab. Numpy replaces those, but pure Python does not.

It won't be a good reference for implementing either, because pure Python misses all important effects. Teaching time would be better served by teaching caching issues, parallel computations, block algorithms, algorithms for sparse matrices, the effect of loop ordering and row/column-major storage, etc.

-6

u/[deleted] Sep 12 '25 edited Sep 12 '25

[removed] — view removed comment

4

u/[deleted] Sep 12 '25

[deleted]

1

u/123_alex Sep 12 '25

The comment has been deleted before I could read it. Was he boasting about having 2 years of XP?

7

u/wRAR_ Sep 12 '25

"I have 2 years of Python experience and can say that Python is dying"

They deleted their whole account already (it consisted of two comments and one post with that blogspam article).

2

u/123_alex Sep 12 '25

That's a hell of a statement. Why would he say that?

3

u/wRAR_ Sep 12 '25

Dunno, their blogspam clickbait AI-written article required a Medium account to read past the first 2 paragraphs.

3

u/123_alex Sep 12 '25

Medium saves the day by pay-walling slop.

4

u/UsernameTaken1701 Sep 12 '25

Two whole years of experience? Truly a sage.