0

A handy Python library

 2 years ago
source link: http://www.donghao.org/2022/01/14/a-handy-python-library/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

A handy Python library

To find an easy way to print the runtime of a function, I found an interesting Python library: funcy.

We can directly use decorator ‘@print_durations()’ like this:

from funcy import print_durations

@print_durations()
def my_func1():
  ...
Python
xxxxxxxxxx
from funcy import print_durations
@print_durations()
def my_func1():
  ...

There are also some other interesting decorators:

@memoize
def ip_to_city(ip):
  ...
Python
xxxxxxxxxx
@memoize
def ip_to_city(ip):
  ...

Like this:

Loading...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK