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.56.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.56-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: versionedfunction-0.9.56.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.56.tar.gz
Algorithm Hash digest
SHA256 db835bd32b9e7fecaa814615b70f16383b88fa6946154b5c67b45e9309680f40
MD5 56c1ca6d4fd81b55d234fe4af621395e
BLAKE2b-256 6bf4d493d705f31fc92734caefa00499dbb35b5f493c7502f9c73fb707e8bff8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: versionedfunction-0.9.56-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.56-py3-none-any.whl
Algorithm Hash digest
SHA256 833785fd6c839a9da7b4857667dabd79afb558c56dda99b0639707538721a5d1
MD5 1667d0b7a36c2f788395831836189aa9
BLAKE2b-256 87d45037941afe7ac6efdc2759516e84d4f4ed031faaa9af85442401da550776

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