Verfun
Verfun is a util for generating a checksum for a python function ignoring whitespace, comments, variable names, etc.
Great, why is this useful?
Given a use case where you want to
- Version an algorithm that did something to your data
- Rerun said algorithm on affected data if the algorithm changes
- not rerun if you only add comments, refactor variable names, etc
Features:
Generating a md5 checksum of a given function, ignoring the following:
- function name
- docstrings and comments
- whitespace
- indentation
Example usage
Example taken from example.py
from verfun import version_hash_for_function, version_hash_for_function_list
def some_strange_looking_function(param1, callback_fn):
tail = param1[-1]
return callback_fn(tail)
def same_strange_looking_function(param1, callback_fn):
"""
This function is documented, but the function is identical to some_strange_looking_function
and should result in the same hash
"""
tail = param1[-1]
# return the callback value from the tail of param whatever that is
return callback_fn(tail)
def different_function():
return "this one is different"
# generate checksum for each function
print(version_hash_for_function(some_strange_looking_function))
# c4cb4d2638d790016cbee29a6ed5af8c
print(version_hash_for_function(same_strange_looking_function))
# c4cb4d2638d790016cbee29a6ed5af8c
print(version_hash_for_function(different_function))
# 8515c1678211e93362800b30ef7234cf
# generate a checksum for multiple functions
print(version_hash_for_function_list([some_strange_looking_function, different_function]))
# 1fa4dc521f63cd5a8faac4cc8402d63d
Release files for verfun 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| verfun-0.2.1.tar.gz | 2.3 kB | Details |
Release files / verfun-0.2.1.tar.gz
| Download URL | verfun-0.2.1.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e6b49a90b2e65ff26c13d6502f2ab102cc719e492cb31d963aec3f7a62f5c29
|
|
BLAKE2b-256 checksum How to use checksums |
95a5158b7dd16e8b224a885caae17da8a2d05f6feedd3b133547a370a1d9a603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/43.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.7
|