Skip to main content

Sometimes you want to be able to dynamically call different versions of a function

Project description

versionedfunction

Sometimes you want to be able to dynamically call different versions of a function.

  • testing alternatives against each other
  • runtime "always on" support for versions code changes

Example

from versionedfunction import versionedfunction, versionedcontext


class Foo():
    @versionedfunction
    def algo(self):
        return 0

    @algo.version
    def algo1(self):
        return 1

    @algo.version
    @algo.default
    def algo2(self):
        return 2


foo = Foo()

# the default is algo2
assert foo.algo() == 2

with versionedcontext(Foo.algo):
    # choose Foo.algo
    assert foo.algo() == 0

@versionedcontext(Foo.algo1)
def some_method():
    assert foo.algo() == 1

Installing

$ pip install versionedfunction

The source code is currently hosted on GitHub at https://github.com/GistLabs/versionedfunction and published in PyPI at https://pypi.org/project/versionedfunction/

The versioning scheme currently used is {major}.{minor}.{auto build number} from git rev-list --count HEAD.

We recommend picking a version like:

versionedfunction = "^0.9"

Community guidelines

We welcome contributions and questions. Please head over to github and send us pull requests or create issues!

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

versionedfunction-0.9.55.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

versionedfunction-0.9.55-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file versionedfunction-0.9.55.tar.gz.

File metadata

  • Download URL: versionedfunction-0.9.55.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.4 Linux/5.15.0-1041-azure

File hashes

Hashes for versionedfunction-0.9.55.tar.gz
Algorithm Hash digest
SHA256 9f2a7bc98aff342365b205e20d8521c1a3de2ede7f900bb68682d67f48d7b74f
MD5 8ec17970bfc88b764954918b1b39e17a
BLAKE2b-256 5e141f4f4083171d07b9030384ed221f3562f4957ec231d65975d2b8b2f56ae7

See more details on using hashes here.

File details

Details for the file versionedfunction-0.9.55-py3-none-any.whl.

File metadata

  • Download URL: versionedfunction-0.9.55-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.4 Linux/5.15.0-1041-azure

File hashes

Hashes for versionedfunction-0.9.55-py3-none-any.whl
Algorithm Hash digest
SHA256 4a37748ba29a0e9571392b5f9151cb65ae1622570970320359d1b04e4b1f1da1
MD5 f9ad8b5ce7370dec3cccafefbab37f23
BLAKE2b-256 c3d73f6108abbeb720b2a030221c7b3cd0ed3b28b6d3c80ec006ba1ec53bd0c9

See more details on using hashes here.

Supported by

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