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

61

u/WildWouks Dec 21 '20

This is awesome. I have a application which I am struggling to get right. It will be a CLI interface. Will definitely look at typer and rich.

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

2

u/ChemEngandTripHop Dec 22 '20

Thanks that was really informative. I'm just reaching the stage where I'm having to wrangle Fire for my more complex use-cases, will give Typer a shot!

1

u/dslfdslj Dec 22 '20

Do you know what the advantage of click over argparse is? Can it do something the other cannot do?

2

u/mechamotoman Dec 23 '20

It's very subjective, but my personal view is that click strikes a better balance between ease of use and capability

Anything you can do in Click could be done with argparse, but it would take a lot more effort

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

6

u/uncanneyvalley Dec 22 '20

I haven't used Typer, but the same dude made FastAPI and it's amazing

4

u/ChemEngandTripHop Dec 22 '20

Yeah Tiangolo is a beast, when I realised he wrote it that was almost enough to convince me to switch on its own

-8

u/GiantElectron Dec 22 '20

I find his overuse of emoji in commit messages highly unprofessional.

1

u/ChemEngandTripHop Dec 22 '20

He's not spattering them all over the place, they're related to the content and consistent. Personally I find they let me sift through the commits more quickly than plain text alone

9

u/Here0s0Johnny Dec 21 '20

6

u/dekked_ Dec 21 '20

I completely missed glacier. Thanks for that, it looks very cool!

2

u/jpflathead Dec 22 '20

wow, glacier seems quite nice

1

u/Here0s0Johnny Dec 22 '20

True, it's very ... cool. 🤓

4

u/ElevenPhonons Dec 22 '20

Here's a listing of a few other libs for creating CLI tools that are leveraging type annotations.

https://github.com/mpkocher/pydantic-cli#other-related-tools