r/Python • • Dec 21 '20

Discussion We hand-picked the best Python libraries released in 2020

Hello,

Every year, we produce a list of the top 10 Python libraries released or popularized that year.

2020 was a hard one, since there are so many good choices! Therefore, we decided we should list many more :) Most are around data science / machine learning.

The full list is available here: https://tryolabs.com/blog/2020/12/21/top-10-python-libraries-of-2020/

So:

  • What do you think about our picks?

  • Did we miss any good one? Especially non-data science libraries.

1.3k Upvotes

73 comments sorted by

View all comments

Show parent comments

17

u/ChemEngandTripHop Dec 21 '20

Does anyone know how Typer compares to Fire?

13

u/mechamotoman Dec 22 '20

Having used both, I'd say typer os miles ahead

I used to think if you've got a simple project you should use Fire, and if you've got a complex project you should use Click

Not to dunk on Fire or anything, it's a solid library. The problem with it is that it only really works well for super simple CLIs. Once you get into more complicated stuff, you find yourself having to contort your codebase into knots to get it to do what you want.

Click on the other hand is really powerful, and doesn't really limit you a whole lot, but the learning curve is steep, and there's a fair amount of boilerplate you need to put in if you want a simple CLI that can scale up in complexity as needed

The problem is that these two libraries have massively different APIs and design patterns. Once you realize the Fire no longer fits the bill, you're looking at quite possibly massive refactoring to switch over to click

Typer hits that sweet spot in the middle. It's super easy to work with for simple CLIs, Scales up super well, is capable of doing almost everything Click can do (it's built on click) and it's so much easier to use the Click

And the best part is, you use the exact same design pattern for simple CLIs as you do for complex CLIs, so it's really simple and straightforward to scale up as your project grows in complexity

0

u/GiantElectron Dec 22 '20

What's the point of typer if it does everything that click does? only for type hints? It's not much of an improvement.

1

u/mechamotoman Dec 23 '20

The API is much cleaner, it has core built-in support for things which either can't easily be done in click or can't be done at all without additional packages, It's (IMO) much easier to use, It allows you to avoid data duplication (you don't need to declare each input to your CLI functions twice like you do with Click) And best of all (IMO), you can actually use your CLI functions as functions after registering them as CLI commands! (For the uninitiated, on click when you register a function to be used as a Click command in your CLI, the Click command decorator transforms your function into a special Click object that can't be used as a function

Overall, I'd say typer took all the things that make Click amazing and fantastic, and refined them into a new API that is more approachable, more enjoyable to use, and more flexible