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.57.tar.gz (7.6 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.57-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: versionedfunction-0.9.57.tar.gz
  • Upload date:
  • Size: 7.6 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.57.tar.gz
Algorithm Hash digest
SHA256 c6f895961a55b84d9e4b5b9ccce4323f21791a6801e6ff41fbb5e9e1c2cea909
MD5 93b287c2d08bb41fbdf5894ec4b8dfd4
BLAKE2b-256 7dfa09fc600e6fa6564d81dcd8a5d49ba581277df93c258e8afd9b23a6e85511

See more details on using hashes here.

File details

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

File metadata

  • Download URL: versionedfunction-0.9.57-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.57-py3-none-any.whl
Algorithm Hash digest
SHA256 d3ae88e6e5edd70b57cfa3f591cfd06641c1ee527b834723e8d45e6e561b8954
MD5 b62f2bd356bc41f6d269771d41f10eb5
BLAKE2b-256 8fe16c34ae108e1b8121e6ff99945e92d669b9e557cfbfa4ccc2f96bad2810e6

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