Should you be using Pathlib?

I've been working in Python for four years - recently I made the conscious choice to use pathlib rather than the more familiar os & os.path.

It's been a great experience - I wrote a short piece (friend link) comparing the two libraries on common workflows & tasks done with file paths.

Should you be using Pathlib?

22 comments · 89% upvoted · other discussions

comments

AaronOpfer

I found myself in a situation where using the os.path family of functions had better performance characteristics than using pathlib, which makes sense as pathlib is a wrapper around them. However most programs won't have that bottleneck and pathlib is nice for them.