GithubHelp home page GithubHelp logo

crvidya / python-datafork Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apparentlymart/python-datafork

0.0 2.0 0.0 118 KB

Forkable global state

Home Page: http://datafork.readthedocs.org/en/latest/

License: MIT License

Python 100.00%

python-datafork's Introduction

datafork

datafork is a Python utility library for creating data slots whose content can be temporarily "forked", possibly mutated, and then merged back into what was already present.

This allows for code to evaluate "what if" scenarios, and then conditionally merge the result depending on whether the outcome was acceptable.

This model could be thought of as a sort of "transactional memory", though it also evokes the idea of dynamic scope.

The simplest use-case is a transaction block whose side-effects apply only if the block runs to completion without raising an exception:

import datafork

with datafork.root() as root:
    example_slot = root.slot(initial_value=1)
    with root.transaction():
        example_slot.value = 2
        might_raise_exception()
    # this will print 1 if an exception was raised, or 2 if not.
    print example_slot.value

For other examples and reference documentation, see the manual.

Installation

Stable versions of this module can be installed from pypi as datafork.

Development Environment Setup

If you'd like to contribute to this library you can clone this repository and run the following steps to get set up. This assumes you already have Python installed, and virtualenv available.

  • virtualenv env
  • source env/bin/activate
  • pip install -r requirements-dev.txt

You should then be able to run the tests by running nosetests.

Contributing

Contributions are welcome but please ensure that any changes are tested and that code style follows what's already present. The baseline code style for this library is PEP8.

python-datafork's People

Contributors

apparentlymart avatar crvidya avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.