Skip to main content

Verfun

Build Status

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

  1. Version an algorithm that did something to your data
  2. Rerun said algorithm on affected data if the algorithm changes
  3. 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

Metadata

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)

Source distribution for verfun 0.2.1
File Size Uploaded Provenance Actions
verfun-0.2.1.tar.gz 2.3 kB Without provenance Details for verfun-0.2.1.tar.gz

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

Security for verfun 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page