{ "info": { "author": "Danilo Horta", "author_email": "horta@ebi.ac.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent" ], "description": "pickle-mixin\n============\n\n|PyPI-License| |PyPI-Version|\n\nMakes un-pickle-able objects pick-able.\n\nInstall\n-------\n\nYou can install it via pip\n\n::\n\n pip install pickle-mixin\n\nRunning the tests\n-----------------\n\nAfter installation, you can test it\n\n::\n\n python -c \"import pickle_mixin; pickle_mixin.test()\"\n\nas long as you have `pytest `__.\n\nUsage\n-----\n\nPickle by initialisation\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nSuppose that you have a class whose objects are un-pickle-able or that\nwould demand a large amount of disk space or memory to be pickle-able.\n``PickleByInit`` class lets you pickle object attributes via object\ninitialization. Consider the following classes:\n\n.. code:: python\n\n class Foo(PickleByInit):\n def __init__(self, obj):\n super(Foo, self).__init__()\n self.obj = obj\n\n class Bar(object):\n def __init__(self, filename):\n self.filename = filename\n\n def __getstate__(self):\n raise PicklingError\n\n def init_dict(self):\n return dict(filename=self.filename)\n\nTrying to pickle as follows\n\n.. code:: python\n\n f = Foo(Bar('file.txt'))\n pickle.dumps(f)\n\nwould raise a ``PicklingError``. The following on the other hand would\nwork:\n\n.. code:: python\n\n f = Foo(Bar('file.txt'))\n f.set_signature_only_attr('obj')\n pickle.dumps(f)\n\nThe un-pickling process of ``f.obj`` attribute happens via object\ninitialisation, passing the returned dictionary from ``init_dict`` as\nkeyword arguments to ``Bar.__init__``.\n\nMixing classes with and without slots\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nPickling does not save attributes defined via ``__slots__`` in the\nfollowing case:\n\n.. code:: python\n\n class Foo(object):\n __slots__ = ['a']\n\n def __init__(self):\n self.a = 4\n\n\n class Bar(Foo):\n def __init__(self):\n pass\n\n``SlotPickleMixin`` fixes it:\n\n.. code:: python\n\n class FooMixin(object):\n __slots__ = ['a']\n\n def __init__(self):\n self.a = 4\n\n\n class BarMixin(FooMixin, SlotPickleMixin):\n def __init__(self):\n FooMixin.__init__(self)\n SlotPickleMixin.__init__(self)\n\n f = BarMixin()\n o = pickle.dumps(f)\n f = pickle.loads(o)\n assert hasattr(f, 'a')\n\nAuthors\n-------\n\n- **Danilo Horta** - https://github.com/Horta\n\nLicense\n-------\n\nThis project is licensed under the MIT License - see the\n`LICENSE `__ file for details\n\n.. |PyPI-License| image:: https://img.shields.io/pypi/l/pickle-mixin.svg?style=flat-square\n :target: https://pypi.python.org/pypi/pickle-mixin/\n.. |PyPI-Version| image:: https://img.shields.io/pypi/v/pickle-mixin.svg?style=flat-square\n :target: https://pypi.python.org/pypi/pickle-mixin/", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/limix/pickle-mixin", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pickle-mixin", "package_url": "https://pypi.org/project/pickle-mixin/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pickle-mixin/", "project_urls": { "Homepage": "https://github.com/limix/pickle-mixin" }, "release_url": "https://pypi.org/project/pickle-mixin/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "Makes un-pickle-able objects pick-able.", "version": "1.0.2" }, "last_serial": 2764746, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "ddb6ddd3ea8bb4ebd45fd226c18e629d", "sha256": "93775a799b322eeb71ee7a0d59252f515f5bd36da2110c6ea78faec552ba1650" }, "downloads": -1, "filename": "pickle-mixin-1.0.0.tar.gz", "has_sig": false, "md5_digest": "ddb6ddd3ea8bb4ebd45fd226c18e629d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4148, "upload_time": "2017-02-15T12:33:00", "url": "https://files.pythonhosted.org/packages/34/94/24b3db2a125824a2641cb86c1203dd6e9933099a047595a60ec646781b18/pickle-mixin-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "f7cf7effe56e7699d50124c7ae342ae8", "sha256": "cd9cc128f102fe8fb907dadb4182391078443e1ffa0ae9fd564a9214f4387953" }, "downloads": -1, "filename": "pickle-mixin-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f7cf7effe56e7699d50124c7ae342ae8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4457, "upload_time": "2017-04-09T21:50:37", "url": "https://files.pythonhosted.org/packages/e9/5e/4432a3b1ac83266e7e0e877abb137df1911a2e0adf7b4082255d6c9b180a/pickle-mixin-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "69bb840886237f83f86869a79736d6d4", "sha256": "d4983cd09939f6e402c69ba4f4200f2e6ccdfd39c020f6d1091290d78f17625c" }, "downloads": -1, "filename": "pickle-mixin-1.0.2.tar.gz", "has_sig": false, "md5_digest": "69bb840886237f83f86869a79736d6d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5113, "upload_time": "2017-04-09T22:30:44", "url": "https://files.pythonhosted.org/packages/02/77/9d5eb2201bbc130e2a5cc41fc949e4ab0da74b619107eac1c511be3af7a7/pickle-mixin-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "69bb840886237f83f86869a79736d6d4", "sha256": "d4983cd09939f6e402c69ba4f4200f2e6ccdfd39c020f6d1091290d78f17625c" }, "downloads": -1, "filename": "pickle-mixin-1.0.2.tar.gz", "has_sig": false, "md5_digest": "69bb840886237f83f86869a79736d6d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5113, "upload_time": "2017-04-09T22:30:44", "url": "https://files.pythonhosted.org/packages/02/77/9d5eb2201bbc130e2a5cc41fc949e4ab0da74b619107eac1c511be3af7a7/pickle-mixin-1.0.2.tar.gz" } ] }