{ "info": { "author": "Dmytro Katyukha", "author_email": "firemage.dima@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "lxmlrpc - XMLRPClib patch\r\n=========================\r\n\r\nThis module monkeypatch python's `xmlrpclib` to use `lxml `__ based parser\r\nto reduce memory consumption on big xmlrpc requests / responses (100+ Mb)\r\n\r\n\r\nNOTE\r\n----\r\n\r\nThis module is useful only for ***python2.7***.\r\n\r\nUse it **only** if you suffer from **high memory consumption** of **xmlrpclib**\r\n\r\n\r\nInstall\r\n-------\r\n\r\nThis module is hosted on `PyPI `__\r\nso it could bu easily installed via *pip*:\r\n\r\n.. code:: bash\r\n\r\n pip install lxmlrpc_monkey\r\n\r\n\r\nUsage\r\n-----\r\n\r\nTo use this module just do following\r\n\r\n.. code:: python\r\n\r\n import xmlrpclib\r\n from lxmlrpc_monkey import patch_xmlrpclib\r\n # This line will monkey-patch xmlrpclib to use lxml for parser\r\n patch_xmlrpclib()\r\n\r\n\r\nBenchmarks (how to run)\r\n-----------------------\r\n\r\nTo run benchmarks:\r\n\r\n1. install `memory_profiler `__\r\n2. prepare data with ``python generate_data.py --path --size 50000000``\r\n3. run benchmarks with ``python benchmark.py --path ``\r\n\r\n\r\n\r\nBenchmark results (50 Mb (real 65 Mb) data file)\r\n================================================\r\n\r\nlook at ```p.feed(data)``` call in ```loads``` function of *xmlrpclib*\r\n\r\n***Running unpatched loads***\r\n\r\nFilename: /usr/lib/python2.7/xmlrpclib.py\r\n\r\n====== ========= ========= =============\r\nLine # Mem usage Increment Line Contents\r\n====== ========= ========= =============\r\n 1134 104.7 MiB 0.0 MiB def loads(data, use_datetime=0):\r\n 1135 \"\"\"data -> unmarshalled data, method name\r\n 1136 \r\n 1137 Convert an XML-RPC packet to unmarshalled data plus a method\r\n 1138 name (None if not present).\r\n 1139 \r\n 1140 If the XML-RPC packet represents a fault condition, this function\r\n 1141 raises a Fault exception.\r\n 1142 \"\"\"\r\n 1143 104.7 MiB 0.0 MiB p, u = getparser(use_datetime=use_datetime)\r\n >1144 622.4 MiB 517.7 MiB p.feed(data)\r\n 1145 558.0 MiB -64.4 MiB p.close()\r\n 1146 558.0 MiB 0.0 MiB return u.close(), u.getmethodname()\r\n====== ========= ========= =============\r\n\r\n\r\n***Running patched loads***\r\n\r\nFilename: /usr/lib/python2.7/xmlrpclib.py\r\n\r\n====== ========= ========= =============\r\nLine # Mem usage Increment Line Contents\r\n====== ========= ========= =============\r\n 1134 106.9 MiB 0.0 MiB def loads(data, use_datetime=0):\r\n 1135 \"\"\"data -> unmarshalled data, method name\r\n 1136 \r\n 1137 Convert an XML-RPC packet to unmarshalled data plus a method\r\n 1138 name (None if not present).\r\n 1139 \r\n 1140 If the XML-RPC packet represents a fault condition, this function\r\n 1141 raises a Fault exception.\r\n 1142 \"\"\"\r\n 1143 106.9 MiB 0.0 MiB p, u = getparser(use_datetime=use_datetime)\r\n >1144 235.9 MiB 129.0 MiB p.feed(data)\r\n 1145 171.5 MiB -64.4 MiB p.close()\r\n 1146 171.5 MiB 0.0 MiB return u.close(), u.getmethodname()\r\n====== ========= ========= =============\r\n\r\n\r\nFilename: bechmark.py\r\n\r\n====== ========= ========= =============\r\nLine # Mem usage Increment Line Contents\r\n====== ========= ========= =============\r\n 13 104.7 MiB 0.0 MiB @profile\r\n 14 def bench_load(xmldata):\r\n 15 104.7 MiB 0.0 MiB print (\"Running unpatched loads\")\r\n 16 106.9 MiB 2.2 MiB loads(xmldata)\r\n 17 \r\n 18 106.9 MiB 0.0 MiB lxmlrpc.patch_xmlrpclib()\r\n 19 \r\n 20 106.9 MiB 0.0 MiB print (\"Running patched loads\")\r\n 21 107.1 MiB 0.2 MiB loads(xmldata)\r\n====== ========= ========= =============\r\n\r\n\r\n\r\nBenchmark results (100 Mb (real 129 Mb) data file)\r\n==================================================\r\n\r\n***Running unpatched loads***\r\n\r\n---\r\n\r\nFilename: /usr/lib/python2.7/xmlrpclib.py\r\n\r\n====== ========== ========== =============\r\nLine # Mem usage Increment Line Contents\r\n====== ========== ========== =============\r\n 1134 169.2 MiB 0.0 MiB def loads(data, use_datetime=0):\r\n 1135 \"\"\"data -> unmarshalled data, method name\r\n 1136 \r\n 1137 Convert an XML-RPC packet to unmarshalled data plus a method\r\n 1138 name (None if not present).\r\n 1139 \r\n 1140 If the XML-RPC packet represents a fault condition, this function\r\n 1141 raises a Fault exception.\r\n 1142 \"\"\"\r\n 1143 169.2 MiB 0.0 MiB p, u = getparser(use_datetime=use_datetime)\r\n >1144 1203.0 MiB 1033.8 MiB p.feed(data)\r\n 1145 1074.2 MiB -128.8 MiB p.close()\r\n 1146 1074.2 MiB 0.0 MiB return u.close(), u.getmethodname()\r\n====== ========== ========== =============\r\n\r\n***Running patched loads***\r\n\r\n---\r\n\r\nFilename: /usr/lib/python2.7/xmlrpclib.py\r\n\r\n====== ========== ========== =============\r\nLine # Mem usage Increment Line Contents\r\n====== ========== ========== =============\r\n 1134 171.6 MiB 0.0 MiB def loads(data, use_datetime=0):\r\n 1135 \"\"\"data -> unmarshalled data, method name\r\n 1136 \r\n 1137 Convert an XML-RPC packet to unmarshalled data plus a method\r\n 1138 name (None if not present).\r\n 1139 \r\n 1140 If the XML-RPC packet represents a fault condition, this function\r\n 1141 raises a Fault exception.\r\n 1142 \"\"\"\r\n 1143 171.6 MiB 0.0 MiB p, u = getparser(use_datetime=use_datetime)\r\n >1144 429.4 MiB 257.8 MiB p.feed(data)\r\n 1145 300.6 MiB -128.8 MiB p.close()\r\n 1146 300.6 MiB 0.0 MiB return u.close(), u.getmethodname()\r\n====== ========== ========== =============\r\n\r\nFilename: bechmark.py\r\n\r\n====== ========== ========== =============\r\nLine # Mem usage Increment Line Contents\r\n====== ========== ========== =============\r\n 13 169.2 MiB 0.0 MiB @profile\r\n 14 def bench_load(xmldata):\r\n 15 169.2 MiB 0.0 MiB print (\"Running unpatched loads\")\r\n 16 171.6 MiB 2.4 MiB loads(xmldata)\r\n 17 \r\n 18 171.6 MiB 0.0 MiB lxmlrpc.patch_xmlrpclib()\r\n 19 \r\n 20 171.6 MiB 0.0 MiB print (\"Running patched loads\")\r\n 21 171.8 MiB 0.2 MiB loads(xmldata)\r\n====== ========== ========== =============", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/katyukha/lxmlrpc_monkey", "keywords": "xmlrpc xmlrpclib xml-rpc", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "lxmlrpc_monkey", "package_url": "https://pypi.org/project/lxmlrpc_monkey/", "platform": "", "project_url": "https://pypi.org/project/lxmlrpc_monkey/", "project_urls": { "Homepage": "https://github.com/katyukha/lxmlrpc_monkey" }, "release_url": "https://pypi.org/project/lxmlrpc_monkey/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "xmlrpclib patch to reduce its memory consumption", "version": "1.0.0" }, "last_serial": 2967505, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "83c99047c6a7269bf9394b3fa0178151", "sha256": "80f11dfdcde8c9584160d044d4b373ca808c975350aeb6d0742b5e712784f34c" }, "downloads": -1, "filename": "lxmlrpc_monkey-1.0.0-py2-none-any.whl", "has_sig": false, "md5_digest": "83c99047c6a7269bf9394b3fa0178151", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 5945, "upload_time": "2017-06-22T09:22:27", "url": "https://files.pythonhosted.org/packages/6f/10/d0c86cff6edb38e673b2c125fcab0a2e0b3447fd944e885f3849dc6ec5ad/lxmlrpc_monkey-1.0.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d817707b476e8e77b5fd8e422a0a5839", "sha256": "999373a2726d4d1d359728e81b7cc1871af48cf28ff18be45b48d852d1e3a682" }, "downloads": -1, "filename": "lxmlrpc_monkey-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d817707b476e8e77b5fd8e422a0a5839", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4238, "upload_time": "2017-06-22T09:22:26", "url": "https://files.pythonhosted.org/packages/cb/16/177b997fa7506bed52a75eb8311d510dac48a21d8b3260ea6441de969869/lxmlrpc_monkey-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "83c99047c6a7269bf9394b3fa0178151", "sha256": "80f11dfdcde8c9584160d044d4b373ca808c975350aeb6d0742b5e712784f34c" }, "downloads": -1, "filename": "lxmlrpc_monkey-1.0.0-py2-none-any.whl", "has_sig": false, "md5_digest": "83c99047c6a7269bf9394b3fa0178151", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 5945, "upload_time": "2017-06-22T09:22:27", "url": "https://files.pythonhosted.org/packages/6f/10/d0c86cff6edb38e673b2c125fcab0a2e0b3447fd944e885f3849dc6ec5ad/lxmlrpc_monkey-1.0.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d817707b476e8e77b5fd8e422a0a5839", "sha256": "999373a2726d4d1d359728e81b7cc1871af48cf28ff18be45b48d852d1e3a682" }, "downloads": -1, "filename": "lxmlrpc_monkey-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d817707b476e8e77b5fd8e422a0a5839", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4238, "upload_time": "2017-06-22T09:22:26", "url": "https://files.pythonhosted.org/packages/cb/16/177b997fa7506bed52a75eb8311d510dac48a21d8b3260ea6441de969869/lxmlrpc_monkey-1.0.0.tar.gz" } ] }