flati


Nameflati JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/ikegami-yukino/flati
SummaryFlatten nested iterable object (Pure-Python)
upload_time2025-08-02 04:01:38
maintainerNone
docs_urlNone
authorYukino Ikegami
requires_pythonNone
licenseMIT License
keywords flatten generator pure-python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            flati
==========
|pyversion| |version| |license|

Flatten nested iterable object (Pure-Python implementation)

Japanese document is available: https://qiita.com/yukinoi/items/9570c76034c28bdae0a8

Installation
==============

::

 $ pip install flati


Usage
============

.. code:: python

  import flati

  iterable = [(1, 2, 3), (4, (5, 6))]
  list(flati.flatten(iterable))
  # => [1, 2, 3, 4, 5, 6]

  # flati.flatten() returns a generator
  import types
  isinstance(flati.flatten(iterable), types.GeneratorType)
  # => True

  # If you want to avoid flattening specific type, then use "ignore" parameter
  iterable = [('abc'), ('def', ('g', 'hi'))]
  list(flati.flatten(iterable, ignore=str))
  # => ['abc', 'def', 'g', 'hi']

Tips
------
If you want to flatten numpy.ndarray, I recommend using following methods:

* numpy.ravel()
* ndarray.reshape(-1)
* ndarray.flatten()  # This method is a bit slow because it makes a copy

Contribution
=============
Contributions are welcome.

See https://github.com/ikegami-yukino/flati/blob/master/CONTRIBUTING.md


.. |pyversion| image:: https://img.shields.io/pypi/pyversions/flati.svg

.. |version| image:: https://img.shields.io/pypi/v/flati.svg
    :target: http://pypi.python.org/pypi/flati/
    :alt: latest version

.. |license| image:: https://img.shields.io/pypi/l/flati.svg
    :target: http://pypi.python.org/pypi/flati/
    :alt: license


CHANGES
=======

0.2.0 (2025-08-02)
------------------

- Add stub files according to PEP 561
- Support Python 3.9, 3.10, 3.11, 3.12, 3.13

0.1.2 (2019-12-31)
------------------

- Support Python 3.8

0.1.1 (2019-1-28)
------------------

- Support Python 2.7

0.1 (2019-1-27)
------------------

- First release

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ikegami-yukino/flati",
    "name": "flati",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "flatten, generator, pure-python",
    "author": "Yukino Ikegami",
    "author_email": "yknikgm@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/d3/b4a43e342459d5473ba222161c2fb797645e4c2ab7dd9be422da264b9396/flati-0.2.0.tar.gz",
    "platform": "POSIX",
    "description": "flati\n==========\n|pyversion| |version| |license|\n\nFlatten nested iterable object (Pure-Python implementation)\n\nJapanese document is available: https://qiita.com/yukinoi/items/9570c76034c28bdae0a8\n\nInstallation\n==============\n\n::\n\n $ pip install flati\n\n\nUsage\n============\n\n.. code:: python\n\n  import flati\n\n  iterable = [(1, 2, 3), (4, (5, 6))]\n  list(flati.flatten(iterable))\n  # => [1, 2, 3, 4, 5, 6]\n\n  # flati.flatten() returns a generator\n  import types\n  isinstance(flati.flatten(iterable), types.GeneratorType)\n  # => True\n\n  # If you want to avoid flattening specific type, then use \"ignore\" parameter\n  iterable = [('abc'), ('def', ('g', 'hi'))]\n  list(flati.flatten(iterable, ignore=str))\n  # => ['abc', 'def', 'g', 'hi']\n\nTips\n------\nIf you want to flatten numpy.ndarray, I recommend using following methods:\n\n* numpy.ravel()\n* ndarray.reshape(-1)\n* ndarray.flatten()  # This method is a bit slow because it makes a copy\n\nContribution\n=============\nContributions are welcome.\n\nSee https://github.com/ikegami-yukino/flati/blob/master/CONTRIBUTING.md\n\n\n.. |pyversion| image:: https://img.shields.io/pypi/pyversions/flati.svg\n\n.. |version| image:: https://img.shields.io/pypi/v/flati.svg\n    :target: http://pypi.python.org/pypi/flati/\n    :alt: latest version\n\n.. |license| image:: https://img.shields.io/pypi/l/flati.svg\n    :target: http://pypi.python.org/pypi/flati/\n    :alt: license\n\n\nCHANGES\n=======\n\n0.2.0 (2025-08-02)\n------------------\n\n- Add stub files according to PEP 561\n- Support Python 3.9, 3.10, 3.11, 3.12, 3.13\n\n0.1.2 (2019-12-31)\n------------------\n\n- Support Python 3.8\n\n0.1.1 (2019-1-28)\n------------------\n\n- Support Python 2.7\n\n0.1 (2019-1-27)\n------------------\n\n- First release\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Flatten nested iterable object (Pure-Python)",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/ikegami-yukino/flati"
    },
    "split_keywords": [
        "flatten",
        " generator",
        " pure-python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "621506dd59015ad55ced3513be521768484a7d83423a76b568e21e32432d9f6a",
                "md5": "cc786dfa86cb6f5c6372dc400a2a0ac4",
                "sha256": "ebae960707516531efdb439471fe9a1aace15cb09ade8a51f927c5ae7fb1f786"
            },
            "downloads": -1,
            "filename": "flati-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cc786dfa86cb6f5c6372dc400a2a0ac4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5890,
            "upload_time": "2025-08-02T04:01:37",
            "upload_time_iso_8601": "2025-08-02T04:01:37.671169Z",
            "url": "https://files.pythonhosted.org/packages/62/15/06dd59015ad55ced3513be521768484a7d83423a76b568e21e32432d9f6a/flati-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7cd3b4a43e342459d5473ba222161c2fb797645e4c2ab7dd9be422da264b9396",
                "md5": "02c308166f08c865cc0c5de10acba320",
                "sha256": "c51da6a3192eed131c9840564047a0f9186e2ac3d48d51cfe4318ce51829cf77"
            },
            "downloads": -1,
            "filename": "flati-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "02c308166f08c865cc0c5de10acba320",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3922,
            "upload_time": "2025-08-02T04:01:38",
            "upload_time_iso_8601": "2025-08-02T04:01:38.944602Z",
            "url": "https://files.pythonhosted.org/packages/7c/d3/b4a43e342459d5473ba222161c2fb797645e4c2ab7dd9be422da264b9396/flati-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-02 04:01:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ikegami-yukino",
    "github_project": "flati",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flati"
}
        
Elapsed time: 1.49009s