Skip to main content

A package for efficient programming

Project description

efficiency

Pypi Downloads Downloads MIT_License

This is a package of useful one-line logging functions made by Zhijing.

Installation

Requirement: Python 3

pip install --upgrade  git+https://github.com/zhijing-jin/efficiency.git

Logging Shortcuts

Obtain time:

>>> from efficiency.log import show_time, fwrite
>>> time_stamp = show_time()
	time: 11241933-41
>>> time_stamp
'11241933' # means: Nov 24th, 19:33

Writing out to files by one line:

>>> text = "This is handy!"
>>> fwrite(text, "temp.txt")

Printing out variables (name + value) easily:

>>> num1 = 7
>>> num2 = 2
>>> num3 = 9
>>> show_var(["num1", "num2", "num3"])
num1 : 7
num2 : 2
num3 : 9

ML-Related

>>> from efficiency.log import gpu_mem
>>> gpu_mem(gpu_id=0)
4101 # Currently, GPU Memory of GPU #0 is 4101 MiB
>>> from efficiency.function import set_seed
>>> set_seed(0)
[Info] seed set to: 0 # set the seed for random, numpy and pytorch

Useful Functions

>>> from efficiency.function import shell
>>> stdout, stderr = shell("cat temp.txt")
>>> stdout
b'This is handy!'

Miscellaneous Functions

Formatting README.md Better

This is the way to automatically generate table of contents for an .md file using markdown_toc:

# Step 1. download the file to your local execution path `/usr/local/bin/`
curl \
  https://raw.githubusercontent.com/alexharv074/markdown_toc/master/mdtoc.rb -o \
  /usr/local/bin/mdtoc.rb

# Step 2. generate the ToC in the "copy" mode
mdtoc.rb README.md

# Alternatively, you can automatically add the content to your copyboard and paste it to your .md
mdtoc.rb README.md | pbcopy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

efficiency-1.4.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

efficiency-1.4-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file efficiency-1.4.tar.gz.

File metadata

  • Download URL: efficiency-1.4.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for efficiency-1.4.tar.gz
Algorithm Hash digest
SHA256 2f2ba4ff6697b5d686347e8c05ff5ec487eb855e2db37c73573fc4c4b65b9ef1
MD5 c16edf374759bc9293f7399e445cc84c
BLAKE2b-256 49bd2e70efc99f5681355686e53b9cb10e74e0d94bd3566a3f510740cc60183c

See more details on using hashes here.

File details

Details for the file efficiency-1.4-py3-none-any.whl.

File metadata

  • Download URL: efficiency-1.4-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for efficiency-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b16c3e900fd0380dac8d086f0c02779af946c3604c71fa3038c3d817a6cffae5
MD5 afbbbe343ceedabdfc8ab9581ee7acf8
BLAKE2b-256 5403ecbe21b237d308da3dd6f7caefcfdde1354150140157b598ecc71f2fd3d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page