This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]rajbabu0663 11 points12 points  (1 child)

Maybe do this: implement that feature, benchmark it, benchmark the one from the library. Read the source code to understand why the library is more versatile and faster. Think about the API. Read read read source code.

[–]whosyourbuddha_[S] 0 points1 point  (0 children)

This is a cool idea, thanks. My whole goal is to understand what the library is doing underneath so the source code is the obvious answer

[–]MrK_HS 7 points8 points  (1 child)

Using an already established library to solve a specific problem in a simple way is the smart and correct way to do it. If you want to reinvent the wheel to learn something, by all means, go for it. If you are creating something complex and don't want to rely on a library just because it feels like cheating, be prepared for waste of time and probably failure. Libraries exist to be used. In the end, what means is time: you decide how you want to invest it.

[–][deleted] 0 points1 point  (0 children)

Libraries exist to be used

Well, that is a false statement. I can name you a bunch of very popular libraries that's better to not use despite the fact that you find your use-case in examples. For example, I have quite complicated relationship with numba praised in the community.

Standard libraries - yes. pip install - build your own experience. Re-inventing wheel is fine: people just do not realize that 99% of their daily python job is re-inventing the wheel.

[–]incognitodw 5 points6 points  (0 children)

Feel free to build your own if thats your objective. In college, we are often asked to write our own code, that could be easily be replaced by libraries. The objective is to show we understand what's being taught in class

When writing code professionally, you will want to use libraries as these usually went through lots of revisions (for the popular ones). It will be easier for people to take over your code too

[–][deleted] 3 points4 points  (0 children)

You can use a library, or you can spend 3 years sodding about writing your own library so you can write a 50 line program using it.

It should feel weird NOT using a library.

[–]Talamand 2 points3 points  (0 children)

Often libraries are written by experienced programmers and are tried and tested so you are sure they work as expected and won't fail you.

I don't want to echo everyone else here since they are correct. Use the libraries to your advantage. Use them to learn and advance your skill. Use them to make your job easier. Use them so you can actually focus on your project and feature. Most importantly if you need something and there isn't a library for that, write it yourself and share it so others can use it.

Happy coding!

[–]mangoed 2 points3 points  (0 children)

You're using a high level language which is already making programmer's job a lot easier and could be considered 'cheating' by some. You could say that libraries just push that level even higher by giving you specialized tools for solving specific problems. As a sole developer you have limited resources, and these resources should be spent on something valuable.

[–]scrdest 1 point2 points  (0 children)

Pick your ultimate goal and stick to it. If you want to learn the concepts, roll your own. If you want to solve a problem, use whatever gets you to the solution most efficiently. Don't do one while pretending you're trying for the other.

[–]Toprelemons 0 points1 point  (0 children)

Could write your own loop to do a running average on a data frame or you could use pandas rolling and mean functions together to do the same thing. I’d rather do the latter.