{ "info": { "author": "Matthew Rocklin", "author_email": "mrocklin@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Unification\n===========\n\n|Build Status|\n\nStraightforward Unification, extensible via dispatch.\n\nExamples\n--------\n\n.. code-block:: python\n\n >>> from unification import *\n >>> unify(1, 1)\n {}\n >>> unify(1, 2)\n False\n >>> x = var('x')\n\n >>> unify((1, x), (1, 2))\n {~x: 2}\n\n >>> unify((x, x), (1, 2))\n False\n\n @unifiable\n class Account(object):\n def __init__(self, id, name, balance):\n self.id = id\n self.name = name\n self.balance = balance\n\n data = [Account(1, 'Alice', 100),\n Account(2, 'Bob', 0),\n Account(2, 'Charlie', 0),\n Account(2, 'Denis', 400),\n Account(2, 'Edith', 500)]\n\n id, name, balance = var('id'), var('name'), var('balance')\n\n >>> [unify(Account(id, name, balance), acct) for acct in data]\n [{~name: 'Alice', ~balance: 100, ~id: 1},\n {~name: 'Bob', ~balance: 0, ~id: 2},\n {~name: 'Charlie', ~balance: 0, ~id: 2},\n {~name: 'Denis', ~balance: 400, ~id: 2},\n {~name: 'Edith', ~balance: 500, ~id: 2}]\n\n >>> [unify(Account(id, name, 0), acct) for acct in data]\n [False,\n {~name: 'Bob', ~id: 2},\n {~name: 'Charlie', ~id: 2},\n False,\n False]\n\nFunction Dispatch\n-----------------\n\nUnification supports function dispatch through pattern matching.\n\n\n.. code-block:: python\n\n from unification.match import *\n\n n = var('n')\n @match(0)\n def fib(n):\n return 0\n\n @match(1)\n def fib(n):\n return 1\n\n @match(n)\n def fib(n):\n return fib(n - 1) + fib(n - 2)\n\n >>> map(fib, [0, 1, 2, 3, 4, 5, 6, 7, 8, 0])\n [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n\n\nThis patten matching can be fairly complex\n\n.. code-block:: python\n\n name, amount = var('name'), var('amount')\n\n @match({'status': 200, 'data': {'name': name, 'credit': amount}})\n def respond(name, amount):\n balance[name] += amount\n\n\n @match({'status': 200, 'data': {'name': name, 'debit': amount}})\n def respond(name, amount):\n balance[name] -= amount\n\n\n @match({'status': 404})\n def respond():\n print(\"Bad Request\")\n\n\nSee full example in the examples directory.\n\n\nPerformance and Reliability\n---------------------------\n\nThis was hacked together. Unification stresses extensibility over performance,\npreliminary benchmarks show that this is 2-5x slower than straight tuple-based\nunification.\n\nThis is somewhat reliable, the only caveat is on set unification which is\nchallenging to do generally within this framework. It should work well in\nmoderately complex cases but break down under very complex ones.\n\n\nHistory\n-------\n\nThis was carved out from the LogPy_ and `Multiple Dispatch`_ projects.\n\n\nAuthor\n------\n\n`Matthew Rocklin`_\n\n\n.. _LogPy: http://github.com/logpy/logpy/\n.. _`Multiple Dispatch`: http://github.com/mrocklin/multipledispatch/\n.. _`Matthew Rocklin`: http://matthewrocklin.com/\n.. |Build Status| image:: https://travis-ci.org/mrocklin/unification.png\n :target: https://travis-ci.org/mrocklin/unification", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/mrocklin/unification/", "keywords": "unification logic-programming dispatch", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "unification", "package_url": "https://pypi.org/project/unification/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/unification/", "project_urls": { "Homepage": "http://github.com/mrocklin/unification/" }, "release_url": "https://pypi.org/project/unification/0.2.2/", "requires_dist": [ "multipledispatch", "toolz" ], "requires_python": "", "summary": "Unification", "version": "0.2.2" }, "last_serial": 2046085, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "85f2cb81f5eccbd5f034610fc5bda033", "sha256": "bf600c8041d8e5afac04dbc53ea5b3e9813cade3cede0c565435ceeea4753f7d" }, "downloads": -1, "filename": "unification-0.2.0.tar.gz", "has_sig": false, "md5_digest": "85f2cb81f5eccbd5f034610fc5bda033", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6041, "upload_time": "2014-07-04T15:13:55", "url": "https://files.pythonhosted.org/packages/f4/1e/59ab5efd620ee0168b5aa11e28669474594237cdd27e226615ac036a21fb/unification-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "ed46c07c9bdb039bb002148468e241d3", "sha256": "3089ce11f07f02ed45bc67398fec969a5956913e45128ef0e9111f4588b17f15" }, "downloads": -1, "filename": "unification-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ed46c07c9bdb039bb002148468e241d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6495, "upload_time": "2014-07-04T16:14:47", "url": "https://files.pythonhosted.org/packages/69/9b/a4176ae231068bcb2676c2c4f7dc3c594f2e420641da0e5552db09a4a13f/unification-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "dec42ab2e9c0130204e4fcec534d540c", "sha256": "fbf883f0ec618a34b806a830afae2f51833d9db013b520519707b34d7f20c282" }, "downloads": -1, "filename": "unification-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dec42ab2e9c0130204e4fcec534d540c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10087, "upload_time": "2016-04-05T01:02:50", "url": "https://files.pythonhosted.org/packages/f2/6d/24285df596df88923ceea78d980f5dabd1c511e562d9ec1db305fc7c43cd/unification-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b2f1723d75b0f5c34a7e9be4137eafbf", "sha256": "e83972eda9a365b51eee97d72436136bfd44b0146f06bb7e8a28cca3eafc79b3" }, "downloads": -1, "filename": "unification-0.2.2.tar.gz", "has_sig": false, "md5_digest": "b2f1723d75b0f5c34a7e9be4137eafbf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6832, "upload_time": "2016-04-05T01:02:57", "url": "https://files.pythonhosted.org/packages/1c/26/432ea4a47aded7b0d64662fc265252da2b2a059f92af2eeb3321d60c9f8a/unification-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dec42ab2e9c0130204e4fcec534d540c", "sha256": "fbf883f0ec618a34b806a830afae2f51833d9db013b520519707b34d7f20c282" }, "downloads": -1, "filename": "unification-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dec42ab2e9c0130204e4fcec534d540c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10087, "upload_time": "2016-04-05T01:02:50", "url": "https://files.pythonhosted.org/packages/f2/6d/24285df596df88923ceea78d980f5dabd1c511e562d9ec1db305fc7c43cd/unification-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b2f1723d75b0f5c34a7e9be4137eafbf", "sha256": "e83972eda9a365b51eee97d72436136bfd44b0146f06bb7e8a28cca3eafc79b3" }, "downloads": -1, "filename": "unification-0.2.2.tar.gz", "has_sig": false, "md5_digest": "b2f1723d75b0f5c34a7e9be4137eafbf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6832, "upload_time": "2016-04-05T01:02:57", "url": "https://files.pythonhosted.org/packages/1c/26/432ea4a47aded7b0d64662fc265252da2b2a059f92af2eeb3321d60c9f8a/unification-0.2.2.tar.gz" } ] }