Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand Python Library

2025-04-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to understand the Python library". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand the Python library".

1. Typer

You may not need to write CLI applications, but sometimes you do. After the great success of FastAPI, tiangolo used the same principle to develop typo, a new library that allows you to use the type prompt feature of Python 3.6 + to write a command line interface.

In addition to ensuring that your code is properly documented, you can also get a CLI interface with validation more quickly. By using type hints, you can automatically complete the code in an editor (such as VSCode), greatly improving your work efficiency.

To enhance its features, Typer can also be used with the command line artifact Click, which means that Typer can take full advantage of all the advantages and plug-ins of Click and implement more complex functions according to its own needs.

Open source address: https://github.com/tiangolo/typer

2. Rich

Who says terminal applications must be single black and white? In fact, it can also be color.

Do you want to add colors and styles to the terminal? Do you want your terminal to print complex forms quickly? Do you want to easily display beautiful progress bars and Emojis? All of the above features can be implemented in Rich. Just take a look at the screenshot below:

This library takes the experience of terminal applications to a whole new level.

Open source address: https://github.com/willmcgugan/rich

3. Dear PyGui

Although Rich can make your terminal applications beautiful, sometimes it's not enough, what you need is a real GUI,Dear PyGui is an easy-to-use, powerful Python GUI framework.

Dear PyGui uses the just-in-time mode paradigm that is popular in video games. This basically means that dynamic GUI is drawn frame by frame independently, without the need to persist any data. This is where Dear PyGui is different from other Python GUI frameworks. The high performance of Dear PyGui is what you often need in engineering, simulation, games, or data science applications.

Dear PyGui supports Windows 10 (DirectX 11), Linux (OpenGL 3) and MacOS (Metal)

Open source address: https://github.com/hoffstadt/DearPyGui

4. PrettyErrors

PrettyErrors is a tool to simplify Python error messages. PrettyErrors only does one thing. It supports color output on the terminal and marks the file stack trace. In this way, you don't have to scan the entire screen to find the abnormal parts.

Open source address: https://github.com/onelivesleft/PrettyErrors

5. Diagrams

We programmers like to solve problems and write code, but sometimes we need to explain complex architectural designs to other colleagues as part of the project documentation. In general, we use the GUI tool to process the chart and visualize the document. But there's a better way.

Diagrams allows you to draw cloud system architectures directly in Python code without any design tools, and its icons are useful for several cloud service providers, including AWS, Azure, and GCP. This makes it very easy to create arrows and groups, and it only takes a few lines of code to do so.

Open source address: https://github.com/mingrammer/diagrams

6. Hydra and OmegaConf

When doing research and experiments in machine learning projects, there are always countless settings to try, and configuration management can become very complex in important applications, if only there is a structured way to deal with these challenges.

Hydra allows you to build configurations in a combinable way and overwrite certain parts from the command line or configuration file. Here's an example of how to use Hydra to define a basic configuration and then use them to run multiple incompatible tasks:

Python train_model.py variation=option_a,option_b

Open source address: https://github.com/facebookresearch/hydra

7. PyTorch Lightning

Every tool that can improve the productivity of data science teams is very valuable. PyTorch Lightning improves efficiency by separating science from engineering. It's a bit like TensorFlow's Keras. In a sense, it makes your code more concise, but it's still PyTorch, and you can still access all the commonly used api.

This library automates more than 40 parts of DL / ML research, such as GPU training, distributed GPU (cluster) training, TPU training, etc.

Open source address: https://github.com/PyTorchLightning/PyTorch-lightning

8. Hummingbird

Hummingbird is a research result of Microsoft, which can assemble trained ML models into tensor computation, so that there is no need to design new models. It also allows users to use neural network frameworks such as PyTorch to accelerate traditional ML models. Its reasoning API is very similar to the sklearn example and can reuse existing code, but it is implemented with code generated by Hummingbird.

Open source address: https://github.com/microsoft/hummingbird

9. HiPlot

Almost every data scientist has had the experience of dealing with high-dimensional data in their career. Unfortunately, the human brain cannot process this kind of data entirely intuitively, so we have to turn to other technologies.

Earlier this year, Facebook released HiPlot, a lightweight interactive visualization tool that uses parallel graphs and other graphics to help AI researchers discover the correlations and models of high-dimensional data. HiPlot is interactive and extensible, so you can use it on Jupyter Notebooks or on its own server.

Open source address: https://github.com/facebookresearch/hiplot

10. Scalene

As the ecosystem of the Python library becomes more and more complex, we find that the code we write is increasingly dependent on C extensions and multithreaded code. How to test performance is a problem because CPython's built-in parser does not properly handle multithreading and native code.

Scalene is a high-performance CPU memory analyzer that correctly handles multithreaded code and distinguishes the time it takes to run Python and native code. There is no need to modify the code, just use scalene to run the script from the command line, and it can generate a text or HTML report for you, showing the CPU and memory usage of each line of code.

Thank you for your reading, the above is the content of "how to understand the Python library", after the study of this article, I believe you have a deeper understanding of how to understand the Python library, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report