lazychains


Namelazychains JSON
Version 0.2.10 PyPI version JSON
download
home_pagehttps://lazychains.readthedocs.io/en/latest/
SummarySingly linked lists with incremental instantiation of iterators
upload_time2023-10-20 12:15:31
maintainer
docs_urlNone
authorStephen Leach
requires_python>=3.10,<4.0
licenseGPL-3.0-or-later
keywords iterators linked list single lazy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Package Description

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/sfkleach/lazychains/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/sfkleach/lazychains/tree/main) [![Documentation Status](https://readthedocs.org/projects/lazychains/badge/?version=latest)](https://lazychains.readthedocs.io/en/latest/?badge=latest)

A Python library to provide "chains", which are Lisp-like singly linked lists 
that support the lazy expansion of iterators. For example, we can construct a 
Chain of three characters from the iterable "abc" and it initially starts as 
unexpanded, shown by the three dots:

```py
>>> from lazychains import lazychain
>>> c = lazychain( "abc")
>>> c
chain([...])
```

We can force the expansion of *c* by performing (say) a lookup or by forcing the whole
chain of items by calling expand:

```py
>>> c[1]                   # Force the expansion of the next 2 elements.
True
>>> c
chain(['a','b',...])
>>> c.expand()             # Force the expansion of the whole chain.
chain(['a','b','c'])
```

Chain are typically a lot less efficient than using ordinary arrays. So,
almost all the time you should carry on using ordinary arrays and/or tuples.
But Chains have a couple of special features that makes them the 
perfect choice for some problems.

   * Chains are immutable and hence can safely share their trailing segments.
   * Chains can make it easy to work with extremely large (or infinite) 
     sequences.

Expanded or Unexpanded
----------------------

When you construct a chain from an iterator, you can choose whether or not
it should be immediately expanded by calling chain rather than lazychain.
The difference between the two is pictured below. First we can see what happens
in the example given above where we create the chain using lazychain on 
"abc".

![chain](https://user-images.githubusercontent.com/1164439/215340284-4b7b44a7-df32-4b90-b925-f0a395694805.png)

By contrast, we would immediately go to a fully expanded chain if we were to
simply apply chain:

```py
>>> from lazychains import chain
>>> c = chain( "abc" )
>>> c
chain(['a','b','c'])
>>> 
```

![lazychain](https://user-images.githubusercontent.com/1164439/215340294-1667798e-dcad-402e-bccb-e0423f1e8ed9.png)


            

Raw data

            {
    "_id": null,
    "home_page": "https://lazychains.readthedocs.io/en/latest/",
    "name": "lazychains",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "iterators,linked list,single,lazy",
    "author": "Stephen Leach",
    "author_email": "sfkleach@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b8/4a/6d54cf7035d79311355d1fde5f16e78cc52696bc26ed45e41505a2c447d8/lazychains-0.2.10.tar.gz",
    "platform": null,
    "description": "# Package Description\n\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/sfkleach/lazychains/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/sfkleach/lazychains/tree/main) [![Documentation Status](https://readthedocs.org/projects/lazychains/badge/?version=latest)](https://lazychains.readthedocs.io/en/latest/?badge=latest)\n\nA Python library to provide \"chains\", which are Lisp-like singly linked lists \nthat support the lazy expansion of iterators. For example, we can construct a \nChain of three characters from the iterable \"abc\" and it initially starts as \nunexpanded, shown by the three dots:\n\n```py\n>>> from lazychains import lazychain\n>>> c = lazychain( \"abc\")\n>>> c\nchain([...])\n```\n\nWe can force the expansion of *c* by performing (say) a lookup or by forcing the whole\nchain of items by calling expand:\n\n```py\n>>> c[1]                   # Force the expansion of the next 2 elements.\nTrue\n>>> c\nchain(['a','b',...])\n>>> c.expand()             # Force the expansion of the whole chain.\nchain(['a','b','c'])\n```\n\nChain are typically a lot less efficient than using ordinary arrays. So,\nalmost all the time you should carry on using ordinary arrays and/or tuples.\nBut Chains have a couple of special features that makes them the \nperfect choice for some problems.\n\n   * Chains are immutable and hence can safely share their trailing segments.\n   * Chains can make it easy to work with extremely large (or infinite) \n     sequences.\n\nExpanded or Unexpanded\n----------------------\n\nWhen you construct a chain from an iterator, you can choose whether or not\nit should be immediately expanded by calling chain rather than lazychain.\nThe difference between the two is pictured below. First we can see what happens\nin the example given above where we create the chain using lazychain on \n\"abc\".\n\n![chain](https://user-images.githubusercontent.com/1164439/215340284-4b7b44a7-df32-4b90-b925-f0a395694805.png)\n\nBy contrast, we would immediately go to a fully expanded chain if we were to\nsimply apply chain:\n\n```py\n>>> from lazychains import chain\n>>> c = chain( \"abc\" )\n>>> c\nchain(['a','b','c'])\n>>> \n```\n\n![lazychain](https://user-images.githubusercontent.com/1164439/215340294-1667798e-dcad-402e-bccb-e0423f1e8ed9.png)\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "Singly linked lists with incremental instantiation of iterators",
    "version": "0.2.10",
    "project_urls": {
        "Documentation": "https://lazychains.readthedocs.io/en/latest/",
        "Homepage": "https://lazychains.readthedocs.io/en/latest/",
        "Repository": "https://github.com/sfkleach/lazychains"
    },
    "split_keywords": [
        "iterators",
        "linked list",
        "single",
        "lazy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6610af13eb2c2ca363b3daea47c06ae7bc5ebfcee228760c98c12a16e6392c43",
                "md5": "61c5be03601394c60cec8e6e5667baa2",
                "sha256": "af2646618506ee997f7b9680c8fa3df6e95db8e45c70cc489552be220eedd554"
            },
            "downloads": -1,
            "filename": "lazychains-0.2.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "61c5be03601394c60cec8e6e5667baa2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 18601,
            "upload_time": "2023-10-20T12:15:30",
            "upload_time_iso_8601": "2023-10-20T12:15:30.117951Z",
            "url": "https://files.pythonhosted.org/packages/66/10/af13eb2c2ca363b3daea47c06ae7bc5ebfcee228760c98c12a16e6392c43/lazychains-0.2.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b84a6d54cf7035d79311355d1fde5f16e78cc52696bc26ed45e41505a2c447d8",
                "md5": "2dd540a55b7673a5ad8a9dc8b1526028",
                "sha256": "064f3efba5250514fff60018f072955c526a3dbf5d0341585213f0fa4d8b6691"
            },
            "downloads": -1,
            "filename": "lazychains-0.2.10.tar.gz",
            "has_sig": false,
            "md5_digest": "2dd540a55b7673a5ad8a9dc8b1526028",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 17856,
            "upload_time": "2023-10-20T12:15:31",
            "upload_time_iso_8601": "2023-10-20T12:15:31.738905Z",
            "url": "https://files.pythonhosted.org/packages/b8/4a/6d54cf7035d79311355d1fde5f16e78cc52696bc26ed45e41505a2c447d8/lazychains-0.2.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-20 12:15:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sfkleach",
    "github_project": "lazychains",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "lcname": "lazychains"
}
        
Elapsed time: 0.12786s