How do you decide between writing your own code and using a Python library?
Frame it as a cost decision. Python's ecosystem makes it easy to add dependencies and easy to end up with forty of them you cannot upgrade.
Use a library when the problem is well-specified and dangerous to get subtly wrong: dates and timezones, cryptography, HTTP with retries and connection pooling, numerical work, or parsing anything with a real grammar. Reimplementing requests or cryptography is not a good use of your week.
Write it yourself when you need a small fraction of what the library offers, or when it drags in a large dependency tree for thirty lines of behaviour.
What to check first:
- Is it maintained — last release date, open issue count, and whether it supports your Python version?
- How many transitive dependencies does it pull in?
- What is the licence, and does it matter for your product?
- How hard would it be to remove in a year?
Note: The standard library is underrated. Candidates regularly reach for a package for something itertools, collections, or pathlib already does.





