diff --git a/changelog/index.html b/changelog/index.html index adfce15..d28473d 100644 --- a/changelog/index.html +++ b/changelog/index.html @@ -542,6 +542,39 @@
reduce
and reduce_await
on Iter[T]
and AsyncIter[T]
to return Option[T]
+ instead of erroring on empty iterators.variable is marker
and variable is no_default
+ to is_marker(variable)
and is_no_default(variable)
respectively.No significant changes.
final
import to be compatible with Python 3.7.typing-aliases
library.async-extensions
is now used instead of reimplementing collect_iterable
functionality.OrderedSet[Q]
private.ordered_set
method to Iter[T]
and AsyncIter[T]
.Predicate[T]
have been updated to accept Optional[Predicate[T]]
.
Passing None
as an argument is identical to passing bool
.take_while
This choice is motivated by the fact that it does not make much sense to do_while(None)
.
async_iter
is now an alias of AsyncIter
;reversed
is now an alias of iter.reversed
.Awaitable[T]
to async functions returning T
.
(#15)await async_iter
, equivalent to await async_iter.list()
.Or by directly specifying it in the configuration like so:
[tool.poetry.dependencies]
-iters = "^0.14.1"
+iters = "^0.15.0"
Alternatively, you can add it directly from the source:
[tool.poetry.dependencies.iters]
diff --git a/objects.inv b/objects.inv
index 6ca28a6..5b06cfd 100644
Binary files a/objects.inv and b/objects.inv differ
diff --git a/reference/async_iters/index.html b/reference/async_iters/index.html
index d1922cf..8ed1f53 100644
--- a/reference/async_iters/index.html
+++ b/reference/async_iters/index.html
@@ -3111,7 +3111,11 @@
2700
2701
2702
-2703
class AsyncIter(AsyncIterator[T]):
+2703
+2704
+2705
+2706
+2707
class AsyncIter(AsyncIterator[T]):
# internals
_iterator: AsyncIterator[T]
@@ -4050,13 +4054,17 @@
async def contains_identity(self: AsyncIter[V], item: V) -> bool:
return await async_contains_identity(item, self.iterator)
- @wrap_future
- async def reduce(self, function: Binary[T, T, T]) -> T:
- return await async_reduce(function, self.iterator)
+ @wrap_future_option
+ async def reduce(self, function: Binary[T, T, T]) -> Option[T]:
+ return wrap_marked(
+ await async_reduce(function, self.iterator, marker) # type: ignore # weird
+ )
- @wrap_future
- async def reduce_await(self, function: AsyncBinary[T, T, T]) -> T:
- return await async_reduce_await(function, self.iterator)
+ @wrap_future_option
+ async def reduce_await(self, function: AsyncBinary[T, T, T]) -> Option[T]:
+ return wrap_marked(
+ await async_reduce_await(function, self.iterator, marker) # type: ignore # weird
+ )
@wrap_future
async def fold(self, initial: V, function: Binary[V, T, V]) -> V:
diff --git a/reference/iters/index.html b/reference/iters/index.html
index edae179..2ac6423 100644
--- a/reference/iters/index.html
+++ b/reference/iters/index.html
@@ -6929,8 +6929,8 @@
def contains_identity(self: Iter[V], item: V) -> bool:
return contains_identity(item, self.iterator)
- def reduce(self, function: Binary[T, T, T]) -> T:
- return reduce(function, self.iterator)
+ def reduce(self, function: Binary[T, T, T]) -> Option[T]:
+ return wrap_marked(reduce(function, self.iterator, marker)) # type: ignore # weird
def fold(self, initial: V, function: Binary[V, T, V]) -> V:
return fold(initial, function, self.iterator)
diff --git a/search/search_index.json b/search/search_index.json
index eff49fe..a03d0ab 100644
--- a/search/search_index.json
+++ b/search/search_index.json
@@ -1 +1 @@
-{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"iters
","text":"
Composable external iteration.
If you have found yourself with a collection of some kind, and needed to perform an operation on the elements of said collection, you will quickly run into iterators. Iterators are heavily used in idiomatic Python code, so becoming familiar with them is essential.
"},{"location":"#installing","title":"Installing","text":"Python 3.8 or above is required.
"},{"location":"#pip","title":"pip","text":"Installing the library with pip
is quite simple:
$ pip install iters\n
Alternatively, the library can be installed from source:
$ git clone https://github.com/nekitdev/iters.git\n$ cd iters\n$ python -m pip install .\n
"},{"location":"#poetry","title":"poetry","text":"You can add iters
as a dependency with the following command:
$ poetry add iters\n
Or by directly specifying it in the configuration like so:
[tool.poetry.dependencies]\niters = \"^0.14.1\"\n
Alternatively, you can add it directly from the source:
[tool.poetry.dependencies.iters]\ngit = \"https://github.com/nekitdev/iters.git\"\n
"},{"location":"#examples","title":"Examples","text":""},{"location":"#simple","title":"Simple","text":"Squaring only even numbers in some sequence:
from iters import iter\n\n\ndef is_even(value: int) -> bool:\n return not value % 2\n\n\ndef square(value: int) -> int:\n return value * value\n\n\nnumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n\nresult = iter(numbers).filter(is_even).map(square).list()\n\nprint(result) # [0, 4, 16, 36, 64]\n
"},{"location":"#asynchronous","title":"Asynchronous","text":"Asynchronous iteration is fully supported by iters
, and its API is similar to its synchronous counterpart.
"},{"location":"#documentation","title":"Documentation","text":"You can find the documentation here.
"},{"location":"#support","title":"Support","text":"If you need support with the library, you can send an email or refer to the official Discord server.
"},{"location":"#changelog","title":"Changelog","text":"You can find the changelog here.
"},{"location":"#security-policy","title":"Security Policy","text":"You can find the Security Policy of iters
here.
"},{"location":"#contributing","title":"Contributing","text":"If you are interested in contributing to iters
, make sure to take a look at the Contributing Guide, as well as the Code of Conduct.
"},{"location":"#license","title":"License","text":"iters
is licensed under the MIT License terms. See License for details.
"},{"location":"changelog/","title":"Changelog","text":""},{"location":"changelog/#0141-2023-12-01","title":"0.14.1 (2023-12-01)","text":"No significant changes.
"},{"location":"changelog/#0140-2023-12-01","title":"0.14.0 (2023-12-01)","text":""},{"location":"changelog/#internal","title":"Internal","text":" - Migrated to Python 3.8.
"},{"location":"changelog/#0131-2023-05-24","title":"0.13.1 (2023-05-24)","text":""},{"location":"changelog/#fixes","title":"Fixes","text":" - Fixed
final
import to be compatible with Python 3.7.
"},{"location":"changelog/#0130-2023-05-21","title":"0.13.0 (2023-05-21)","text":""},{"location":"changelog/#internal_1","title":"Internal","text":" - Migrated to using
typing-aliases
library.
"},{"location":"changelog/#0120-2023-05-10","title":"0.12.0 (2023-05-10)","text":""},{"location":"changelog/#changes","title":"Changes","text":" - This release contains lots of breaking changes. Please refer to the API documentation.
"},{"location":"changelog/#0110-2023-01-29","title":"0.11.0 (2023-01-29)","text":""},{"location":"changelog/#internal_2","title":"Internal","text":" async-extensions
is now used instead of reimplementing collect_iterable
functionality.
"},{"location":"changelog/#0100-2023-01-08","title":"0.10.0 (2023-01-08)","text":""},{"location":"changelog/#internal_3","title":"Internal","text":" - Marked the internals of the
OrderedSet[Q]
private.
"},{"location":"changelog/#090-2023-01-07","title":"0.9.0 (2023-01-07)","text":""},{"location":"changelog/#features","title":"Features","text":" - Added
collect_iter
method for AsyncIter[T]
and Iter[T]
.
"},{"location":"changelog/#080-2022-12-22","title":"0.8.0 (2022-12-22)","text":""},{"location":"changelog/#features_1","title":"Features","text":" - Added
into_iter
method for AsyncIter[T]
. - Added
into_async_iter
method for Iter[T]
.
"},{"location":"changelog/#070-2022-12-20","title":"0.7.0 (2022-12-20)","text":""},{"location":"changelog/#features_2","title":"Features","text":" - Added
OrderedSet[Q]
type within the iters.ordered_set
module. - Added
ordered_set
method to Iter[T]
and AsyncIter[T]
.
"},{"location":"changelog/#060-2022-11-08","title":"0.6.0 (2022-11-08)","text":""},{"location":"changelog/#internal_4","title":"Internal","text":" - Migrated to using
named
and solus
packages instead of reimplementing their functionality. (#18)
"},{"location":"changelog/#050-2022-10-11","title":"0.5.0 (2022-10-11)","text":""},{"location":"changelog/#changes_1","title":"Changes","text":" - Functions taking
Predicate[T]
have been updated to accept Optional[Predicate[T]]
. Passing None
as an argument is identical to passing bool
.
There are three functions which do not accept None
, though: - drop_while
- skip_while
- take_while
This choice is motivated by the fact that it does not make much sense to do_while(None)
.
"},{"location":"changelog/#040-2022-10-08","title":"0.4.0 (2022-10-08)","text":""},{"location":"changelog/#changes_2","title":"Changes","text":" - The following functions have been changed:
async_iter
is now an alias of AsyncIter
; iter
is now an alias of Iter
; reversed
is now an alias of iter.reversed
.
"},{"location":"changelog/#030-2022-08-17","title":"0.3.0 (2022-08-17)","text":""},{"location":"changelog/#changes_3","title":"Changes","text":" - Changed functions of various arity returning
Awaitable[T]
to async functions returning T
. (#15)
"},{"location":"changelog/#020-2022-08-15","title":"0.2.0 (2022-08-15)","text":""},{"location":"changelog/#changes_4","title":"Changes","text":" - Added
await async_iter
, equivalent to await async_iter.list()
.
"},{"location":"changelog/#010-2022-08-01","title":"0.1.0 (2022-08-01)","text":"Initial release.
"},{"location":"code_of_conduct/","title":"Code of Conduct","text":""},{"location":"code_of_conduct/#our-pledge","title":"Our Pledge","text":"We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
"},{"location":"code_of_conduct/#our-standards","title":"Our Standards","text":"Examples of behavior that contributes to a positive environment for our community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
"},{"location":"code_of_conduct/#enforcement-responsibilities","title":"Enforcement Responsibilities","text":"Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
"},{"location":"code_of_conduct/#scope","title":"Scope","text":"This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
"},{"location":"code_of_conduct/#enforcement","title":"Enforcement","text":"Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement to conduct@nekit.dev.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
"},{"location":"code_of_conduct/#enforcement-guidelines","title":"Enforcement Guidelines","text":"Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
"},{"location":"code_of_conduct/#1-correction","title":"1. Correction","text":"Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
"},{"location":"code_of_conduct/#2-warning","title":"2. Warning","text":"Community Impact: A violation through a single incident or series of actions.
Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
"},{"location":"code_of_conduct/#3-temporary-ban","title":"3. Temporary Ban","text":"Community Impact: A serious violation of community standards, including sustained inappropriate behavior.
Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
"},{"location":"code_of_conduct/#4-permanent-ban","title":"4. Permanent Ban","text":"Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
Consequence: A permanent ban from any sort of public interaction within the community.
"},{"location":"code_of_conduct/#attribution","title":"Attribution","text":"This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://contributor-covenant.org/version/2/1/code_of_conduct.
Community Impact Guidelines were inspired by Mozilla's Code of Conduct enforcement ladder.
For answers to common questions about this code of conduct, see the FAQ at https://contributor-covenant.org/faq. Translations are available at https://contributor-covenant.org/translations.
"},{"location":"predicates/","title":"Predicates","text":"iters
defines all predicate
arguments as Optional[Predicate[T]]
where T
is the item type of the iterable.
Passing None
as the predicate argument is equivalent to passing bool
, though most functions are optimized to avoid the overhead of function calls to it.
"},{"location":"security/","title":"Security Policy","text":""},{"location":"security/#reporting","title":"Reporting","text":"Thank you for taking the time to responsibly disclose any problems you find.
Do not file public issues as they are open for everyone to see!
All security vulnerabilities in iters
should be reported by email to security@nekit.dev. Your report will be acknowledged within 24 hours, and you will receive a more detailed response within 48 hours indicating the next steps in handling your report.
You can encrypt your report using our public key: 6AF9DDF87B37BBE6E83F5DF2B8F5B86F98F12F5E
. This key is also available on MIT's Key Server and reproduced below.
After the initial reply to your report, the core team will try to keep you informed of the progress being made towards a fix and official announcement. These updates will be sent at least every five days. In reality, this is more likely to be every 24-48 hours.
"},{"location":"security/#disclosure-policy","title":"Disclosure Policy","text":"iters
has a 5-step disclosure process:
-
The security report is received and is assigned a primary handler. This person will coordinate the fix and release process.
-
The problem is confirmed and a list of all affected versions is determined.
-
Code is audited to find any potential similar problems.
-
Fixes are prepared for all releases which are still under maintenance. These fixes are not committed to the public repository but rather held locally pending the announcement.
-
On the embargo date, the changes are pushed to the public repository and new builds are deployed.
This process can take some time, especially when coordination is required with maintainers of other projects. Every effort will be made to handle the issue in as timely a manner as possible, however it is important that we follow the release process above to ensure that the disclosure is handled in a consistent manner.
"},{"location":"security/#security-key","title":"Security Key","text":"-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGVV4JcBEAC7PTswfzA2iMTVSig51NVDV08XABrR01qslTfhIVw6Uwr2iCoY\nF+hkNn3++pgoF95Fx/iREDFV/AG4GGKl1GbAI3YD6aOoh0FGWtxg3MMa3oHjRUZs\nf0VwKk8sA5d21V05OiMuptAqxXuLrdR5SINtxKE10H6K9o22988VOmWUCIEaxKM5\nM5HCfhe8fl5pKpdIf3i1F073qset4DXGkvm/v+dWYHPvv0NlHhnJ5Lcaq4aTvkEg\ny2NhDobR4VpdP1aQZbEONussUaKLxBTBJN5NNnf7SI1qVYcaglYrXM7uQGXuL32X\nXAILtOCM0LO2059Z7ZMkI6lkkbei1j08j2Tha/1GvN2rIClNyV912GvAQhzlwhdT\nWmk+ymrwbed7MkRW3IB3b1zFb7Dhz6a5yBS8iT5ikkrGaR/i7O3V/DS02j7Rao2k\nnfXIncuBuXSXb1pIhCuYuV6VYBgFWfpKDjOzEy83h3DSI/jrR31e6aiBes+fyFRG\nIuoFRTsaMq2T9M5F6pDvmtoexHxXevYoSt+7DURY1pSWnk4MjZUj7yDFPSyfPleZ\naNq/3aGQt7vnY5QgyGjKaX5jSVuNEKsUlhrKUWt9weoJrF5ZyYHY0RPg1q1Fz0mY\nZ7QWeaKA0uOeziG0bHf6yNEzxnaYCfi09/WOL4GH0pBsdubNHpWno/D6PwARAQAB\ntC9OaWtpdGEgVGlraG9ub3YgKHNlY3VyaXR5KSA8c2VjdXJpdHlAbmVraXQuZGV2\nPokCTgQTAQoAOBYhBGr53fh7N7vm6D9d8rj1uG+Y8S9eBQJlVeCXAhsDBQsJCAcC\nBhUKCQgLAgQWAgMBAh4BAheAAAoJELj1uG+Y8S9ed4kP+wYE1OZtcWoRSK2Xqvaf\nP5+YcXC1vdCZ16depb6kGOR91G9eEMJhSDlSzzUzOmkvT4TknZi/Y17m9TvQccET\nSwgWvDs9XwMby24mkxD1iYu2uIZXXhRbIKJPi4EpGgamEveYLLTd0L8yX2l/YXuq\nVcM4vqgRtnovlW+cCUmmtpRcb+Ldfxu2RixjnG4fznzzlMOnU0zpWUMBqH+mSyfH\nRmY5vgOR/adgQcIviQdhRPMC4TAa3GNdTd2Qpxo3xelum15yLKxkm/EvBSPsL1fj\nJQBYnZFk4KBKNiXXYwWuU0mpOx1TMtYPVnHer17QL0vXfsmVNkXVzucvrNfHpFc9\nhXzmm5wHwMrGClyQBA6sDWDfQOKYibQTcKzyJr2Gl31luNPSRchzC4lbosLzRkqh\nYh5dco+ITiKDe7g54w+Fy+KdumwN/GvBlQptGIpaxA1+xAbNVs+fDo+WrQEL+AZO\nOQR91YUsjIdvVdk5BcgUYvEe2YyyMZ7LSqWACpRknqz5FNcdmO2bz7jl732EYLRm\nQ90oSG6xcIFuPZRNVIUJds9Gg2u1PBV5z0vnFGiJ6NK6DrYYecMKU9uAQUZcSW8v\n+fn92V0DkVeOfeMbq4yytZx5W4VrsWT1XyfjTzg867jzmo1JmZQeZ4KXh7AYRlC6\nn8NwYZ13+pUFeTPm9jCwJMrGuQINBGVV4JcBEACg5zXucth9KIdryYUxyBgA7Ist\nhJmyxtSHSiKRFOiQBmQqHeQgDdCnBeDw+cb+8wB4NL3PNw5xHKRvQGTWaBTV1IPf\nCV3P2c/sZLDCU8PNMu3lsmEbN2ippOiJi1fw478EGlNity8ktI+TEhsdniypKoiw\nDNf3wdawWiraODM9KuYplcsnFHl5r97BjHR0EbOOKkTc4PwysQ7WVHZ/nwGzNb5T\nCI7A/TF0RTL/Wkdz7WZM7r5BELz+z0ksjsS8eMObtm/uG4lfAmbIGohPTlir4WWL\n/GYZpAjvv/6zNaydMpY3uQKrdqN05j10uYnkbsclwSBBbRovFBRWEInbO0cqpzc0\nJiWt4U91F6UNbSDPo3KaiDjJXDb7cr4gQv0C1T9LtmKSfY/JVcUj7csGXslOAvXf\nz08iDCJu3zj7QjZPKA1/MxmTo88hAvhHlOYrXaaRjzXt6r9+qdDxVYJGe9K3LkJS\n9Yc0U9xBGAfzw9Ebs/ZPDtjgupPHJXq6VBSndU3c53jr7SEZBIFMPg75CeJJ6IgH\nA4zwW1uzalZi3mYWWCKiGhDBPOo5yGwKocxMzSuerlMW21fjhOMymSKVksteJlmZ\nAy6ExDNOK663V6iFnsn4iIFbE1jOznHhSsbyKqQ/QukpMqAyrQVSNyutXVl0VuW0\nZsZeFff7ScnrTgB7/QARAQABiQI2BBgBCgAgFiEEavnd+Hs3u+boP13yuPW4b5jx\nL14FAmVV4JcCGwwACgkQuPW4b5jxL15jNw/9EQkahEieTABEKAKxGetODA7HTiNR\ncM3aKgDU0msYjfgfAi+wQzx/8k8Yf/Kjma6JqsksCj0ygFkXS87tOAUfJTpgmKVS\nV3XaDXFwTcdG0+/Cx5RllduJmnLTLSuvm2uxu7ErPGtnYWBw88nmQ/8f9nkmvCsY\nCuF6DHAUNzTLgerFKSGNMwOv6kKBCgNkstclcHp5YbzssN1w34dPV/swuCjc+6JM\nnW5WuPD3R2Y9522Ov/bEwr9raFf3R5A6ETK4GOZUqNmPG4MJgbyiJlk96TuF06mO\nnFpKnBtxD+t20jAFTMRokyiQT65X8KnrpT8CpTJ6xzmBO5IYGhUSqt3CH/YzwqRa\nv9FTJ/qSPM5OXPH4pK7VzNDVhEPQhLAGENLwOnasnXXGvj/MQIRYyjGAXQfB34a7\nz0x4rQ+fyaody6BW10KJBQuRrB3dPaOPU3LU/4TxzyudDxiOJGiWAlw56a2lviEG\nJExMJrSvP5kiCfPlLZiLfqaw2ZYeyosnv8bmC4H2Sr9IEggtCyrzNOoJQx+w/f/L\n6a14Cshc3UYLC+0yh74Mc5vUu2SfwI6zSevjI1LWj4qc592J/q3QNHiJN9F60tyP\nr46uNM25Y+C5qgVneqRjHmWSIdOvYXcBTLj03eDiQHCJz3ZT6ztLwQxQ800MS1Yd\npbmAGLbBB2TBok4=\n=Ir8m\n-----END PGP PUBLIC KEY BLOCK-----\n
"},{"location":"security/#attribution","title":"Attribution","text":"This Security Policy is adapted from Rust's Security Policy.
"},{"location":"reference/async_iters/","title":"Async Iterators","text":""},{"location":"reference/async_iters/#iters.async_iters.AsyncIter","title":"AsyncIter
","text":" Bases: AsyncIterator[T]
Source code in iters/async_iters.py
class AsyncIter(AsyncIterator[T]):\n # internals\n\n _iterator: AsyncIterator[T]\n\n def __init__(self, iterable: AnyIterable[T]) -> None:\n self._iterator = async_iter_any_iter(iterable)\n\n def _replace(self, iterator: AsyncIterator[T]) -> None:\n self._iterator = iterator\n\n # implementation\n\n @property\n def iterator(self) -> AsyncIterator[T]:\n \"\"\"The underlying iterator.\"\"\"\n return self._iterator\n\n @classmethod\n def empty(cls) -> AsyncIter[T]:\n return cls.create(async_empty())\n\n @classmethod\n def of(cls, *items: V) -> AsyncIter[V]:\n return cls.create(async_of(*items))\n\n @classmethod\n def once(cls, value: V) -> AsyncIter[V]:\n return cls.create(async_once(value))\n\n @classmethod\n def once_with(cls, function: Nullary[V]) -> AsyncIter[V]:\n return cls.create(async_once_with(function))\n\n @classmethod\n def once_with_await(cls, function: AsyncNullary[V]) -> AsyncIter[V]:\n return cls.create(async_once_with_await(function))\n\n @classmethod\n def repeat(cls, value: V) -> AsyncIter[V]:\n return cls.create(async_repeat(value))\n\n @classmethod\n def repeat_exactly(cls, value: V, count: int) -> AsyncIter[V]:\n return cls.create(async_repeat(value, count))\n\n @classmethod\n def repeat_with(cls, function: Nullary[V]) -> AsyncIter[V]:\n return cls.create(async_repeat_with(function))\n\n @classmethod\n def repeat_with_await(cls, function: AsyncNullary[V]) -> AsyncIter[V]:\n return cls.create(async_repeat_with_await(function))\n\n @classmethod\n def repeat_exactly_with(cls, function: Nullary[V], count: int) -> AsyncIter[V]:\n return cls.create(async_repeat_with(function, count))\n\n @classmethod\n def repeat_exactly_with_await(cls, function: AsyncNullary[V], count: int) -> AsyncIter[V]:\n return cls.create(async_repeat_with_await(function, count))\n\n @classmethod\n def count_from_by(cls, start: int, step: int) -> AsyncIter[int]:\n return cls.create(async_count(start, step))\n\n @classmethod\n def count_from(cls, start: int) -> AsyncIter[int]:\n return cls.count_from_by(start, DEFAULT_STEP)\n\n @classmethod\n def count_by(cls, step: int) -> AsyncIter[int]:\n return cls.count_from_by(DEFAULT_START, step)\n\n @classmethod\n def count(cls) -> AsyncIter[int]:\n return cls.count_from_by(DEFAULT_START, DEFAULT_STEP)\n\n @classmethod\n def iterate(cls, function: Unary[V, V], value: V) -> AsyncIter[V]:\n return cls.create(async_iterate(function, value))\n\n @classmethod\n def iterate_exactly(cls, function: Unary[V, V], value: V, count: int) -> AsyncIter[V]:\n return cls.create(async_iterate(function, value, count))\n\n @classmethod\n def iterate_await(cls, function: AsyncUnary[V, V], value: V) -> AsyncIter[V]:\n return cls.create(async_iterate_await(function, value))\n\n @classmethod\n def iterate_exactly_await(\n cls, function: AsyncUnary[V, V], value: V, count: int\n ) -> AsyncIter[V]:\n return cls.create(async_iterate_await(function, value, count))\n\n @classmethod\n def iter_except(cls, function: Nullary[T], *errors: AnyErrorType) -> AsyncIter[T]:\n return cls.create(async_iter_except(function, *errors))\n\n @classmethod\n def iter_except_await(cls, function: AsyncNullary[T], *errors: AnyErrorType) -> AsyncIter[T]:\n return cls.create(async_iter_except_await(function, *errors))\n\n @classmethod\n def iter_with(cls, context_manager: ContextManager[AnyIterable[T]]) -> AsyncIter[T]:\n return cls.create(async_iter_with(context_manager))\n\n @classmethod\n def iter_async_with(\n cls, async_context_manager: AsyncContextManager[AnyIterable[T]]\n ) -> AsyncIter[T]:\n return cls.create(async_iter_async_with(async_context_manager))\n\n @classmethod\n def create_chain(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_chain(*iterables))\n\n @classmethod\n def create_chain_with(cls, iterable: AnyIterable[AnyIterable[T]]) -> AsyncIter[T]:\n return cls.create(async_chain_from_iterable(iterable))\n\n @classmethod\n def create_combine(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_combine(*iterables))\n\n @classmethod\n def create_interleave(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_interleave(*iterables))\n\n @classmethod\n def create_interleave_longest(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_interleave_longest(*iterables))\n\n @overload\n @classmethod\n def create_zip(cls) -> AsyncIter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip(cls, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return cls.create(async_zip(*iterables))\n\n @overload\n @classmethod\n def create_zip_equal(cls) -> AsyncIter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_equal(cls, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return cls.create(async_zip_equal(*iterables))\n\n @overload\n @classmethod\n def create_zip_longest(cls) -> AsyncIter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[Option[A]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[Option[A], Option[B]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E], Option[F]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[\n Tuple[\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n ]\n ]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[\n Tuple[\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_longest(\n cls, *iterables: AnyIterable[Any]\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n return cls.create(async_zip_longest(*iterables))\n\n @overload\n @classmethod\n def create_cartesian_product(cls) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_cartesian_product(cls, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return cls.create(async_cartesian_product(*iterables))\n\n @classmethod\n def reversed(cls, reversible: Reversible[T]) -> AsyncIter[T]:\n return cls.create(async_reversed(reversible))\n\n @classmethod\n def function(cls, function: Nullary[T], sentinel: V) -> AsyncIter[T]:\n return cls.create(async_iter_function(function, sentinel))\n\n @classmethod\n def function_await(cls, function: AsyncNullary[T], sentinel: V) -> AsyncIter[T]:\n return cls.create(async_iter_function_await(function, sentinel))\n\n @classmethod\n def create(cls, iterable: AnyIterable[U]) -> AsyncIter[U]:\n return cls(iterable) # type: ignore\n\n @classmethod\n def create_tuple(cls, iterables: DynamicTuple[AnyIterable[U]]) -> DynamicTuple[AsyncIter[U]]:\n return tuple(map(cls, iterables)) # type: ignore\n\n @classmethod\n def create_nested(cls, nested: AnyIterable[AnyIterable[U]]) -> AsyncIter[AsyncIter[U]]:\n return cls(map(cls, nested)) # type: ignore\n\n def __aiter__(self) -> AsyncIter[T]:\n return self\n\n async def __anext__(self) -> T:\n return await async_next_unchecked(self.iterator)\n\n def __await__(self) -> Generator[None, None, List[T]]:\n return self.list().__await__()\n\n def unwrap(self) -> AsyncIterator[T]:\n return self.iterator\n\n def async_iter(self) -> AsyncIter[T]:\n return self\n\n @wrap_future_option\n async def next(self) -> Option[T]:\n return wrap_marked(await async_next_unchecked(self.iterator, marker))\n\n @wrap_future\n async def compare(self: AsyncIter[ST], other: AnyIterable[ST]) -> Ordering:\n return await async_compare(self.iterator, other)\n\n @wrap_future\n async def compare_by(self, other: AnyIterable[T], key: Unary[T, ST]) -> Ordering:\n return await async_compare(self.iterator, other, key)\n\n @wrap_future\n async def compare_by_await(self, other: AnyIterable[T], key: AsyncUnary[T, ST]) -> Ordering:\n return await async_compare_await(self.iterator, other, key)\n\n @wrap_future\n async def length(self) -> int:\n return await async_iter_length(self.iterator)\n\n @wrap_future_option\n async def first(self) -> Option[T]:\n return wrap_marked(await async_first(self.iterator, marker))\n\n @wrap_future_option\n async def last(self) -> Option[T]:\n return wrap_marked(await async_last(self.iterator, marker))\n\n @wrap_future_option\n async def last_with_tail(self) -> Option[T]:\n return wrap_marked(await async_last_with_tail(self.iterator, marker))\n\n def collect(self, function: Unary[AsyncIterable[T], U]) -> U:\n return function(self.iterator)\n\n @wrap_future\n async def collect_await(self, function: AsyncUnary[AsyncIterable[T], U]) -> U:\n return await function(self.iterator)\n\n def collect_iter(self, function: Unary[AsyncIterable[T], AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(self.collect(function))\n\n @wrap_future\n async def list(self) -> List[T]:\n return await async_list(self.iterator)\n\n @wrap_future\n async def set(self: AsyncIter[Q]) -> Set[Q]:\n return await async_set(self.iterator)\n\n @wrap_future\n async def ordered_set(self: AsyncIter[Q]) -> OrderedSet[Q]:\n return await async_ordered_set(self.iterator)\n\n @wrap_future\n async def tuple(self) -> DynamicTuple[T]:\n return await async_tuple(self.iterator)\n\n @wrap_future\n async def dict(self: AsyncIter[Tuple[Q, V]]) -> Dict[Q, V]:\n return await async_dict(self.iterator)\n\n @wrap_future\n async def extract(self) -> Iterator[T]:\n return await async_extract(self.iterator)\n\n @wrap_future\n async def join(self: AsyncIter[AnyStr], string: AnyStr) -> AnyStr:\n return string.join(await self.list())\n\n @wrap_future\n async def string(self: AsyncIter[str]) -> str:\n return await self.join(EMPTY_STRING)\n\n @wrap_future\n async def bytes(self: AsyncIter[bytes]) -> bytes:\n return await self.join(EMPTY_BYTES)\n\n @wrap_future\n async def count_dict(self: AsyncIter[Q]) -> Counter[Q]:\n return await async_count_dict(self.iterator)\n\n @wrap_future\n async def count_dict_by(self, key: Unary[T, Q]) -> Counter[Q]:\n return await async_count_dict(self.iterator, key)\n\n @wrap_future\n async def count_dict_by_await(self, key: AsyncUnary[T, Q]) -> Counter[Q]:\n return await async_count_dict_await(self.iterator, key)\n\n @wrap_future\n async def group_dict(self: AsyncIter[Q]) -> Dict[Q, List[Q]]:\n return await async_group_dict(self.iterator)\n\n @wrap_future\n async def group_dict_by(self, key: Unary[T, Q]) -> Dict[Q, List[T]]:\n return await async_group_dict(self.iterator, key)\n\n @wrap_future\n async def group_dict_by_await(self, key: AsyncUnary[T, Q]) -> Dict[Q, List[T]]:\n return await async_group_dict_await(self.iterator, key)\n\n def group(self) -> AsyncIter[Tuple[T, AsyncIter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n async for group_key, group_iterator in async_group(self.iterator)\n )\n\n def group_by(self, key: Unary[T, U]) -> AsyncIter[Tuple[U, AsyncIter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n async for group_key, group_iterator in async_group(self.iterator, key)\n )\n\n def group_by_await(self, key: AsyncUnary[T, U]) -> AsyncIter[Tuple[U, AsyncIter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n async for group_key, group_iterator in async_group_await(self.iterator, key)\n )\n\n def group_list(self) -> AsyncIter[Tuple[T, List[T]]]:\n return self.create(async_group_list(self.iterator))\n\n def group_list_by(self, key: Unary[T, U]) -> AsyncIter[Tuple[U, List[T]]]:\n return self.create(async_group_list(self.iterator, key))\n\n def group_list_by_await(self, key: AsyncUnary[T, U]) -> AsyncIter[Tuple[U, List[T]]]:\n return self.create(async_group_list_await(self.iterator, key))\n\n @wrap_future\n async def all(self) -> bool:\n return await async_all(self.iterator)\n\n @wrap_future\n async def all_by(self, predicate: Predicate[T]) -> bool:\n return await self.map(predicate).all()\n\n @wrap_future\n async def all_by_await(self, predicate: AsyncPredicate[T]) -> bool:\n return await self.map_await(predicate).all()\n\n @wrap_future\n async def any(self) -> bool:\n return await async_any(self.iterator)\n\n @wrap_future\n async def any_by(self, predicate: Predicate[T]) -> bool:\n return await self.map(predicate).any()\n\n @wrap_future\n async def any_by_await(self, predicate: AsyncPredicate[T]) -> bool:\n return await self.map_await(predicate).any()\n\n @wrap_future\n async def all_equal(self) -> bool:\n return await async_all_equal(self.iterator)\n\n @wrap_future\n async def all_equal_by(self, key: Unary[T, U]) -> bool:\n return await async_all_equal(self.iterator, key)\n\n @wrap_future\n async def all_equal_by_await(self, key: AsyncUnary[T, U]) -> bool:\n return await async_all_equal_await(self.iterator, key)\n\n @wrap_future\n async def all_unique(self) -> bool:\n return await async_all_unique(self.iterator)\n\n @wrap_future\n async def all_unique_by(self, key: Unary[T, U]) -> bool:\n return await async_all_unique(self.iterator, key)\n\n @wrap_future\n async def all_unique_by_await(self, key: AsyncUnary[T, U]) -> bool:\n return await async_all_unique_await(self.iterator, key)\n\n @wrap_future\n async def all_unique_fast(self: AsyncIter[Q]) -> bool:\n return await async_all_unique_fast(self.iterator)\n\n @wrap_future\n async def all_unique_fast_by(self, key: Unary[T, Q]) -> bool:\n return await async_all_unique_fast(self.iterator, key)\n\n @wrap_future\n async def all_unique_fast_by_await(self, key: AsyncUnary[T, Q]) -> bool:\n return await async_all_unique_fast_await(self.iterator, key)\n\n def remove(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_remove(predicate, self.iterator))\n\n def remove_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_remove_await(predicate, self.iterator))\n\n def remove_duplicates(self) -> AsyncIter[T]:\n return self.create(async_remove_duplicates(self.iterator))\n\n def remove_duplicates_by(self, key: Unary[T, U]) -> AsyncIter[T]:\n return self.create(async_remove_duplicates(self.iterator, key))\n\n def remove_duplicates_by_await(self, key: AsyncUnary[T, U]) -> AsyncIter[T]:\n return self.create(async_remove_duplicates_await(self.iterator, key))\n\n def filter(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_filter(predicate, self.iterator))\n\n def filter_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_filter_await(predicate, self.iterator))\n\n def filter_false(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_filter_false(predicate, self.iterator))\n\n def filter_false_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_filter_false_await(predicate, self.iterator))\n\n def filter_except(self, validate: Validate[T], *errors: AnyErrorType) -> AsyncIter[T]:\n return self.create(async_filter_except(validate, self.iterator, *errors))\n\n def filter_except_await(\n self, validate: AsyncValidate[T], *errors: AnyErrorType\n ) -> AsyncIter[T]:\n return self.create(async_filter_except_await(validate, self.iterator, *errors))\n\n def compress(self, selectors: AnySelectors) -> AsyncIter[T]:\n return self.create(async_compress(self.iterator, selectors))\n\n def position_all(self, predicate: Optional[Predicate[T]]) -> AsyncIter[int]:\n return self.create(async_position_all(predicate, self.iterator))\n\n def position_all_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[int]:\n return self.create(async_position_all_await(predicate, self.iterator))\n\n @wrap_future_option\n async def position(self, predicate: Optional[Predicate[T]]) -> Option[int]:\n return wrap_marked(await async_position(predicate, self.iterator, marker))\n\n @wrap_future_option\n async def position_await(self, predicate: AsyncPredicate[T]) -> Option[int]:\n return wrap_marked(await async_position_await(predicate, self.iterator, marker))\n\n def find_all(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_find_all(predicate, self.iterator))\n\n def find_all_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_find_all_await(predicate, self.iterator))\n\n @wrap_future_option\n async def find(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(await async_find(predicate, self.iterator, marker)) # type: ignore\n\n @wrap_future_option\n async def find_await(self, predicate: AsyncPredicate[T]) -> Option[T]:\n return wrap_marked(await async_find_await(predicate, self.iterator, marker)) # type: ignore\n\n @wrap_future_option\n async def find_or_first(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(\n await async_find_or_first(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future_option\n async def find_or_first_await(self, predicate: AsyncPredicate[T]) -> Option[T]:\n return wrap_marked(\n await async_find_or_first_await(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future_option\n async def find_or_last(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(\n await async_find_or_last(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future_option\n async def find_or_last_await(self, predicate: AsyncPredicate[T]) -> Option[T]:\n return wrap_marked(\n await async_find_or_last_await(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future\n async def contains(self, item: V) -> bool:\n return await async_contains(item, self.iterator)\n\n @wrap_future\n async def contains_identity(self: AsyncIter[V], item: V) -> bool:\n return await async_contains_identity(item, self.iterator)\n\n @wrap_future\n async def reduce(self, function: Binary[T, T, T]) -> T:\n return await async_reduce(function, self.iterator)\n\n @wrap_future\n async def reduce_await(self, function: AsyncBinary[T, T, T]) -> T:\n return await async_reduce_await(function, self.iterator)\n\n @wrap_future\n async def fold(self, initial: V, function: Binary[V, T, V]) -> V:\n return await async_fold(initial, function, self.iterator)\n\n @wrap_future\n async def fold_await(self, initial: V, function: AsyncBinary[V, T, V]) -> V:\n return await async_fold_await(initial, function, self.iterator)\n\n @wrap_future\n async def sum(self: AsyncIter[S]) -> S:\n return await async_sum(self.iterator)\n\n @wrap_future\n async def sum_with(self: AsyncIter[S], initial: S) -> S:\n return await async_sum(self.iterator, initial)\n\n @wrap_future\n async def product(self: AsyncIter[P]) -> P:\n return await async_product(self.iterator)\n\n @wrap_future\n async def product_with(self: AsyncIter[P], initial: P) -> P:\n return await async_product(self.iterator, initial)\n\n def accumulate_reduce(self, function: Binary[T, T, T]) -> AsyncIter[T]:\n return self.create(async_accumulate_reduce(function, self.iterator))\n\n def accumulate_reduce_await(self, function: AsyncBinary[T, T, T]) -> AsyncIter[T]:\n return self.create(async_accumulate_reduce_await(function, self.iterator))\n\n def accumulate_fold(self, initial: V, function: Binary[V, T, V]) -> AsyncIter[V]:\n return self.create(async_accumulate_fold(initial, function, self.iterator))\n\n def accumulate_fold_await(self, initial: V, function: AsyncBinary[V, T, V]) -> AsyncIter[V]:\n return self.create(async_accumulate_fold_await(initial, function, self.iterator))\n\n def accumulate_sum(self: AsyncIter[S]) -> AsyncIter[S]:\n return self.create(async_accumulate_sum(self.iterator))\n\n def accumulate_sum_with(self: AsyncIter[S], initial: S) -> AsyncIter[S]:\n return self.create(async_accumulate_sum(self.iterator, initial))\n\n def accumulate_product(self: AsyncIter[P]) -> AsyncIter[P]:\n return self.create(async_accumulate_product(self.iterator))\n\n def accumulate_product_with(self: AsyncIter[P], initial: P) -> AsyncIter[P]:\n return self.create(async_accumulate_product(self.iterator, initial))\n\n @wrap_future_option\n async def min(self: AsyncIter[ST]) -> Option[ST]:\n return wrap_marked(await async_min(self.iterator, default=marker))\n\n @wrap_future_option\n async def min_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(await async_min(self.iterator, key=key, default=marker)) # type: ignore\n\n @wrap_future_option\n async def min_by_await(self, key: AsyncUnary[T, ST]) -> Option[T]:\n return wrap_marked(\n await async_min_await(self.iterator, key=key, default=marker) # type: ignore\n )\n\n @wrap_future_option\n async def max(self: AsyncIter[ST]) -> Option[ST]:\n return wrap_marked(await async_max(self.iterator, default=marker))\n\n @wrap_future_option\n async def max_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(await async_max(self.iterator, key=key, default=marker)) # type: ignore\n\n @wrap_future_option\n async def max_by_await(self, key: AsyncUnary[T, ST]) -> Option[T]:\n return wrap_marked(\n await async_max_await(self.iterator, key=key, default=marker) # type: ignore\n )\n\n @wrap_future_option\n async def min_max(self: AsyncIter[ST]) -> Option[Pair[ST]]:\n return wrap_marked(await async_min_max(self.iterator, default=marker))\n\n @wrap_future_option\n async def min_max_by(self, key: Unary[T, ST]) -> Option[Pair[T]]:\n return wrap_marked(await async_min_max(self.iterator, key=key, default=marker))\n\n @wrap_future_option\n async def min_max_by_await(self, key: AsyncUnary[T, ST]) -> Option[Pair[T]]:\n return wrap_marked(await async_min_max_await(self.iterator, key=key, default=marker))\n\n def map(self, function: Unary[T, U]) -> AsyncIter[U]:\n return self.create(async_map(function, self.iterator))\n\n def map_await(self, function: AsyncUnary[T, U]) -> AsyncIter[U]:\n return self.create(async_map_await(function, self.iterator))\n\n def map_except(self, function: Unary[T, U], *errors: AnyErrorType) -> AsyncIter[U]:\n return self.create(async_map_except(function, self.iterator, *errors))\n\n def map_except_await(self, function: AsyncUnary[T, U], *errors: AnyErrorType) -> AsyncIter[U]:\n return self.create(async_map_except_await(function, self.iterator, *errors))\n\n def map_concurrent(self, function: AsyncUnary[T, U]) -> AsyncIter[U]:\n return self.create(async_map_concurrent(function, self.iterator))\n\n def map_concurrent_bound(self, bound: int, function: AsyncUnary[T, U]) -> AsyncIter[U]:\n return self.create(async_map_concurrent_bound(bound, function, self.iterator))\n\n def flat_map(self, function: Unary[T, AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_flat_map(function, self.iterator))\n\n def flat_map_await(self, function: AsyncUnary[T, AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_flat_map_await(function, self.iterator))\n\n def filter_map(self, predicate: Optional[Predicate[T]], function: Unary[T, U]) -> AsyncIter[U]:\n return self.create(async_filter_map(predicate, function, self.iterator))\n\n def filter_await_map(self, predicate: AsyncPredicate[T], function: Unary[T, U]) -> AsyncIter[U]:\n return self.create(async_filter_await_map(predicate, function, self.iterator))\n\n def filter_map_await(\n self, predicate: Optional[Predicate[T]], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_map_await(predicate, function, self.iterator))\n\n def filter_await_map_await(\n self, predicate: AsyncPredicate[T], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_await_map_await(predicate, function, self.iterator))\n\n def filter_false_map(\n self, predicate: Optional[Predicate[T]], function: Unary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_map(predicate, function, self.iterator))\n\n def filter_false_await_map(\n self, predicate: AsyncPredicate[T], function: Unary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_await_map(predicate, function, self.iterator))\n\n def filter_false_map_await(\n self, predicate: Optional[Predicate[T]], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_map_await(predicate, function, self.iterator))\n\n def filter_false_await_map_await(\n self, predicate: AsyncPredicate[T], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_await_map_await(predicate, function, self.iterator))\n\n def flatten(self: AsyncIter[AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_flatten(self.iterator))\n\n def collapse(self: AsyncIter[RecursiveAnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_collapse(self.iterator))\n\n def enumerate(self) -> AsyncIter[Tuple[int, T]]:\n return self.create(async_enumerate(self.iterator))\n\n def enumerate_from(self, start: int) -> AsyncIter[Tuple[int, T]]:\n return self.create(async_enumerate(self.iterator, start))\n\n @wrap_future\n async def consume(self) -> None:\n await async_consume(self.iterator)\n\n @wrap_future\n async def for_each(self, function: ForEach[T]) -> None:\n await async_for_each(function, self.iterator)\n\n @wrap_future\n async def for_each_await(self, function: AsyncForEach[T]) -> None:\n await async_for_each_await(function, self.iterator)\n\n def append(self: AsyncIter[V], item: V) -> AsyncIter[V]:\n return self.create(async_append(item, self.iterator))\n\n def prepend(self: AsyncIter[V], item: V) -> AsyncIter[V]:\n return self.create(async_prepend(item, self.iterator))\n\n @wrap_future_option\n async def at(self, index: int) -> Option[T]:\n return wrap_marked(await async_at(index, self.iterator, marker))\n\n @wrap_future_option\n async def at_or_last(self, index: int) -> Option[T]:\n return wrap_marked(await async_at_or_last(index, self.iterator, marker))\n\n @overload\n def slice(self, __stop: Optional[int]) -> AsyncIter[T]:\n ...\n\n @overload\n def slice(\n self, __start: Optional[int], __stop: Optional[int], __step: Optional[int] = ...\n ) -> AsyncIter[T]:\n ...\n\n def slice(self, *slice_args: Optional[int]) -> AsyncIter[T]:\n return self.create(async_iter_slice(self.iterator, *slice_args))\n\n def drop(self, size: int) -> AsyncIter[T]:\n return self.create(async_drop(size, self.iterator))\n\n skip = drop\n\n def rest(self) -> AsyncIter[T]:\n return self.create(async_rest(self.iterator))\n\n def drop_while(self, predicate: Predicate[T]) -> AsyncIter[T]:\n return self.create(async_drop_while(predicate, self.iterator))\n\n skip_while = drop_while\n\n def drop_while_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_drop_while_await(predicate, self.iterator))\n\n skip_while_await = drop_while_await\n\n def take(self, size: int) -> AsyncIter[T]:\n return self.create(async_take(size, self.iterator))\n\n def take_while(self, predicate: Predicate[T]) -> AsyncIter[T]:\n return self.create(async_take_while(predicate, self.iterator))\n\n def take_while_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_take_while_await(predicate, self.iterator))\n\n def step_by(self, step: int) -> AsyncIter[T]:\n return self.create(async_step_by(step, self.iterator))\n\n def tail(self, size: int) -> AsyncIter[T]:\n return self.create(async_tail(size, self.iterator))\n\n def apply_chain(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_chain(self.iterator, *iterables))\n\n chain = mixed_method(create_chain, apply_chain)\n\n def apply_chain_with(self, iterables: AnyIterable[AnyIterable[T]]) -> AsyncIter[T]:\n return self.chain(async_chain_from_iterable(iterables))\n\n chain_with = mixed_method(create_chain_with, apply_chain_with)\n\n def cycle(self) -> AsyncIter[T]:\n return self.create(async_cycle(self.iterator))\n\n def intersperse(self: AsyncIter[V], value: V) -> AsyncIter[V]:\n return self.create(async_intersperse(value, self.iterator))\n\n def intersperse_with(self, function: Nullary[T]) -> AsyncIter[T]:\n return self.create(async_intersperse_with(function, self.iterator))\n\n def intersperse_with_await(self, function: AsyncNullary[T]) -> AsyncIter[T]:\n return self.create(async_intersperse_with_await(function, self.iterator))\n\n def apply_interleave(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_interleave(self.iterator, *iterables))\n\n interleave = mixed_method(create_interleave, apply_interleave)\n\n def apply_interleave_longest(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_interleave_longest(self.iterator, *iterables))\n\n interleave_longest = mixed_method(create_interleave_longest, apply_interleave_longest)\n\n def apply_combine(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_combine(*iterables))\n\n combine = mixed_method(create_combine, apply_combine)\n\n @overload\n def distribute_unsafe(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[1]) -> Tuple1[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[2]) -> Tuple2[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[3]) -> Tuple3[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[4]) -> Tuple4[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[5]) -> Tuple5[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[6]) -> Tuple6[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[7]) -> Tuple7[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[8]) -> Tuple8[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n ...\n\n def distribute_unsafe(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n return self.create_tuple(async_distribute_unsafe(count, self.iterator))\n\n distribute_infinite = distribute_unsafe\n\n @overload\n def distribute(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute(self, count: Literal[1]) -> Tuple1[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[2]) -> Tuple2[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[3]) -> Tuple3[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[4]) -> Tuple4[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[5]) -> Tuple5[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[6]) -> Tuple6[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[7]) -> Tuple7[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[8]) -> Tuple8[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n ...\n\n def distribute(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n return self.create_tuple(async_distribute(count, self.iterator))\n\n def divide(self, count: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_divide(count, self.iterator))\n\n def pad(self, value: V) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad(value, self.iterator))\n\n def pad_exactly(self, value: V, size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad(value, self.iterator, size))\n\n def pad_multiple(self, value: V, size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad(value, self.iterator, size, multiple=True))\n\n def pad_none(self) -> AsyncIter[Optional[T]]:\n return self.pad(None)\n\n def pad_none_exactly(self, size: int) -> AsyncIter[Optional[T]]:\n return self.pad_exactly(None, size)\n\n def pad_none_multiple(self, size: int) -> AsyncIter[Optional[T]]:\n return self.pad_multiple(None, size)\n\n def pad_with(self, function: Unary[int, V]) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with(function, self.iterator))\n\n def pad_exactly_with(self, function: Unary[int, V], size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with(function, self.iterator, size))\n\n def pad_multiple_with(self, function: Unary[int, V], size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with(function, self.iterator, size, multiple=True))\n\n def pad_with_await(self, function: AsyncUnary[int, V]) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with_await(function, self.iterator))\n\n def pad_exactly_with_await(\n self, function: AsyncUnary[int, V], size: int\n ) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with_await(function, self.iterator, size))\n\n def pad_multiple_with_await(\n self, function: AsyncUnary[int, V], size: int\n ) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with_await(function, self.iterator, size, multiple=True))\n\n def chunks(self, size: int) -> AsyncIter[List[T]]:\n return self.create(async_chunks(size, self.iterator))\n\n def iter_chunks(self, size: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_iter_chunks(size, self.iterator))\n\n def iter_chunks_unsafe(self, size: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_iter_chunks_unsafe(size, self.iterator))\n\n iter_chunks_infinite = iter_chunks_unsafe\n\n @overload\n def groups(self, size: Literal[0]) -> AsyncIter[Never]:\n ...\n\n @overload\n def groups(self, size: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def groups(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def groups(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_groups(size, self.iterator))\n\n @overload\n def groups_longest(self, size: Literal[0]) -> AsyncIter[Never]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[1]) -> AsyncIter[Tuple1[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[2]) -> AsyncIter[Tuple2[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[3]) -> AsyncIter[Tuple3[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[4]) -> AsyncIter[Tuple4[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[5]) -> AsyncIter[Tuple5[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[6]) -> AsyncIter[Tuple6[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[7]) -> AsyncIter[Tuple7[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[8]) -> AsyncIter[Tuple8[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: int) -> AsyncIter[DynamicTuple[Option[T]]]:\n ...\n\n def groups_longest(self, size: int) -> AsyncIter[DynamicTuple[Option[T]]]:\n return self.create(async_groups_longest(size, self.iterator))\n\n def pairs(self) -> AsyncIter[Pair[T]]:\n return self.create(async_pairs(self.iterator))\n\n def pairs_longest(self) -> AsyncIter[Pair[Option[T]]]:\n return self.create(async_pairs_longest(self.iterator))\n\n def iter_windows(self, size: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_iter_windows(size, self.iterator))\n\n def list_windows(self, size: int) -> AsyncIter[List[T]]:\n return self.create(async_list_windows(size, self.iterator))\n\n def pairs_windows(self) -> AsyncIter[Pair[T]]:\n return self.create(async_pairs_windows(self.iterator))\n\n @overload\n def tuple_windows(self, size: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def tuple_windows(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_tuple_windows(size, self.iterator))\n\n def set_windows(self: AsyncIter[Q], size: int) -> AsyncIter[Set[Q]]:\n return self.create(async_set_windows(size, self.iterator))\n\n @overload\n def apply_zip(self) -> AsyncIter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip(self, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n def apply_zip(self, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return self.create(async_zip(self.iterator, *iterables))\n\n zip = mixed_method(create_zip, apply_zip)\n\n @overload\n def apply_zip_equal(self) -> AsyncIter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip_equal(self, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip_equal(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip_equal( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n def apply_zip_equal(self, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return self.create(async_zip_equal(self.iterator, *iterables))\n\n zip_equal = mixed_method(create_zip_equal, apply_zip_equal)\n\n @overload\n def apply_zip_longest(self) -> AsyncIter[Tuple[Option[T]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: AnyIterable[A]\n ) -> AsyncIter[Tuple[Option[T], Option[A]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n ...\n\n def apply_zip_longest(\n self, *iterables: AnyIterable[Any]\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n return self.create(async_zip_longest(self.iterator, *iterables))\n\n zip_longest = mixed_method(create_zip_longest, apply_zip_longest)\n\n def transpose(self: AsyncIter[AnyIterable[T]]) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_transpose(self.iterator))\n\n @overload\n def apply_cartesian_product(self) -> AsyncIter[Tuple[T]]:\n ...\n\n @overload\n def apply_cartesian_product(self, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_cartesian_product( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n def apply_cartesian_product(self, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return self.create(async_cartesian_product(self.iterator, *iterables))\n\n cartesian_product = mixed_method(create_cartesian_product, apply_cartesian_product)\n\n @overload\n def cartesian_power(self, power: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n def cartesian_power(self, power: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_cartesian_power(power, self.iterator))\n\n @overload\n def combinations(self, count: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def combinations(self, count: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def combinations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def combinations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_combinations(count, self.iterator))\n\n @overload\n def combinations_with_replacement(self, count: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def combinations_with_replacement(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_combinations_with_replacement(count, self.iterator))\n\n def permute(self) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_permute(self.iterator))\n\n @overload\n def permutations(self, count: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def permutations(self, count: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def permutations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def permutations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_permutations(count, self.iterator))\n\n def power_set(self) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_power_set(self.iterator))\n\n def reverse(self) -> AsyncIter[T]:\n return self.create(async_reverse(self.iterator))\n\n @wrap_future\n async def sorted(self: AsyncIter[ST]) -> List[ST]:\n return await async_sorted(self.iterator)\n\n @wrap_future\n async def sorted_by(self, key: Unary[T, ST]) -> List[T]:\n return await async_sorted(self.iterator, key=key)\n\n @wrap_future\n async def sorted_reverse(self: AsyncIter[ST]) -> List[ST]:\n return await async_sorted(self.iterator, reverse=True)\n\n @wrap_future\n async def sorted_reverse_by(self, key: Unary[T, ST]) -> List[T]:\n return await async_sorted(self.iterator, key=key, reverse=True)\n\n @wrap_future\n async def sorted_by_await(self, key: AsyncUnary[T, ST]) -> List[T]:\n return await async_sorted_await(self.iterator, key=key)\n\n @wrap_future\n async def sorted_reverse_by_await(self, key: AsyncUnary[T, ST]) -> List[T]:\n return await async_sorted_await(self.iterator, key=key, reverse=True)\n\n def sort(self: AsyncIter[ST]) -> AsyncIter[ST]:\n return self.create(async_sort(self.iterator))\n\n def sort_by(self, key: Unary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort(self.iterator, key=key))\n\n def sort_reverse(self: AsyncIter[ST]) -> AsyncIter[ST]:\n return self.create(async_sort(self.iterator, reverse=True))\n\n def sort_reverse_by(self, key: Unary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort(self.iterator, key=key, reverse=True))\n\n def sort_by_await(self, key: AsyncUnary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort_await(self.iterator, key=key))\n\n def sort_reverse_by_await(self, key: AsyncUnary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort_await(self.iterator, key=key, reverse=True))\n\n @wrap_future\n async def is_sorted(self: AsyncIter[LT]) -> bool:\n return await async_is_sorted(self.iterator)\n\n @wrap_future\n async def is_sorted_by(self, key: Unary[T, LT]) -> bool:\n return await async_is_sorted(self.iterator, key)\n\n @wrap_future\n async def is_sorted_reverse(self: AsyncIter[LT]) -> bool:\n return await async_is_sorted(self.iterator, reverse=True)\n\n @wrap_future\n async def is_sorted_reverse_by(self, key: Unary[T, LT]) -> bool:\n return await async_is_sorted(self.iterator, key, reverse=True)\n\n @wrap_future\n async def is_sorted_strict(self: AsyncIter[ST]) -> bool:\n return await async_is_sorted(self.iterator, strict=True)\n\n @wrap_future\n async def is_sorted_strict_by(self, key: Unary[T, ST]) -> bool:\n return await async_is_sorted(self.iterator, key, strict=True)\n\n @wrap_future\n async def is_sorted_reverse_strict(self: AsyncIter[ST]) -> bool:\n return await async_is_sorted(self.iterator, strict=True, reverse=True)\n\n @wrap_future\n async def is_sorted_reverse_strict_by(self, key: Unary[T, ST]) -> bool:\n return await async_is_sorted(self.iterator, key, strict=True, reverse=True)\n\n @wrap_future\n async def is_sorted_by_await(self, key: AsyncUnary[T, LT]) -> bool:\n return await async_is_sorted_await(self.iterator, key)\n\n @wrap_future\n async def is_sorted_reverse_by_await(self, key: AsyncUnary[T, LT]) -> bool:\n return await async_is_sorted_await(self.iterator, key, reverse=True)\n\n @wrap_future\n async def is_sorted_strict_by_await(self, key: AsyncUnary[T, ST]) -> bool:\n return await async_is_sorted_await(self.iterator, key, strict=True)\n\n @wrap_future\n async def is_sorted_reverse_strict_by_await(self, key: AsyncUnary[T, ST]) -> bool:\n return await async_is_sorted_await(self.iterator, key, strict=True, reverse=True)\n\n def duplicates_fast(self: AsyncIter[Q]) -> AsyncIter[Q]:\n return self.create(async_duplicates_fast(self.iterator))\n\n def duplicates_fast_by(self, key: Unary[T, Q]) -> AsyncIter[T]:\n return self.create(async_duplicates_fast(self.iterator, key))\n\n def duplicates_fast_by_await(self, key: AsyncUnary[T, Q]) -> AsyncIter[T]:\n return self.create(async_duplicates_fast_await(self.iterator, key))\n\n def duplicates(self) -> AsyncIter[T]:\n return self.create(async_duplicates(self.iterator))\n\n def duplicates_by(self, key: Unary[T, V]) -> AsyncIter[T]:\n return self.create(async_duplicates(self.iterator, key))\n\n def duplicates_by_await(self, key: AsyncUnary[T, V]) -> AsyncIter[T]:\n return self.create(async_duplicates_await(self.iterator, key))\n\n def unique_fast(self: AsyncIter[Q]) -> AsyncIter[Q]:\n return self.create(async_unique_fast(self.iterator))\n\n def unique_fast_by(self, key: Unary[T, Q]) -> AsyncIter[T]:\n return self.create(async_unique_fast(self.iterator, key))\n\n def unique_fast_by_await(self, key: AsyncUnary[T, Q]) -> AsyncIter[T]:\n return self.create(async_unique_fast_await(self.iterator, key))\n\n def unique(self) -> AsyncIter[T]:\n return self.create(async_unique(self.iterator))\n\n def unique_by(self, key: Unary[T, V]) -> AsyncIter[T]:\n return self.create(async_unique(self.iterator, key))\n\n def unique_by_await(self, key: AsyncUnary[T, V]) -> AsyncIter[T]:\n return self.create(async_unique_await(self.iterator, key))\n\n def partition(self, predicate: Optional[Predicate[T]]) -> Pair[AsyncIter[T]]:\n true, false = async_partition(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n def partition_await(self, predicate: AsyncPredicate[T]) -> Pair[AsyncIter[T]]:\n true, false = async_partition_await(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n def partition_unsafe(self, predicate: Optional[Predicate[T]]) -> Pair[AsyncIter[T]]:\n true, false = async_partition_unsafe(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n partition_infinite = partition_unsafe\n\n def partition_unsafe_await(self, predicate: AsyncPredicate[T]) -> Pair[AsyncIter[T]]:\n true, false = async_partition_unsafe_await(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n partition_infinite_await = partition_unsafe_await\n\n def copy(self) -> AsyncIter[T]:\n iterator, result = async_copy(self.iterator)\n\n self._replace(iterator)\n\n return self.create(result)\n\n def copy_unsafe(self) -> AsyncIter[T]:\n iterator, result = async_copy_unsafe(self.iterator)\n\n self._replace(iterator)\n\n return self.create(result)\n\n copy_infinite = copy_unsafe\n\n @wrap_future\n async def spy(self, size: int) -> List[T]:\n result, iterator = await async_spy(size, self.iterator)\n\n self._replace(iterator)\n\n return result\n\n @wrap_future_option\n async def peek(self) -> Option[T]:\n item, iterator = await async_peek(self.iterator, marker)\n\n self._replace(iterator)\n\n return wrap_marked(item)\n\n @wrap_future\n async def has_next(self) -> bool:\n result, iterator = await async_has_next(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n @wrap_future\n async def is_empty(self) -> bool:\n result, iterator = await async_is_empty(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def repeat_last(self) -> AsyncIter[T]:\n return self.create(async_repeat_last(self.iterator))\n\n def repeat_each(self, count: int) -> AsyncIter[T]:\n return self.create(async_repeat_each(count, self.iterator))\n\n def inspect(self, function: Inspect[T]) -> AsyncIter[T]:\n return self.create(async_inspect(function, self.iterator))\n\n def inspect_await(self, function: AsyncInspect[T]) -> AsyncIter[T]:\n return self.create(async_inspect_await(function, self.iterator))\n\n def wait(self: AsyncIter[Awaitable[U]]) -> AsyncIter[U]:\n return self.create(async_wait(self.iterator))\n\n def wait_concurrent(self: AsyncIter[Awaitable[U]]) -> AsyncIter[U]:\n return self.create(async_wait_concurrent(self.iterator))\n\n def wait_concurrent_bound(self: AsyncIter[Awaitable[U]], bound: int) -> AsyncIter[U]:\n return self.create(async_wait_concurrent_bound(bound, self.iterator))\n\n @wrap_future\n async def into_iter(self) -> Iter[T]:\n return iter(await self.extract())\n
"},{"location":"reference/async_iters/#iters.async_iters.AsyncIter.iterator","title":"iterator: AsyncIterator[T]
property
","text":"The underlying iterator.
"},{"location":"reference/async_utils/","title":"Async Utilities","text":""},{"location":"reference/iters/","title":"Iterators","text":""},{"location":"reference/iters/#iters.iters.iter","title":"iter = Iter
module-attribute
","text":"An alias of Iter
.
"},{"location":"reference/iters/#iters.iters.reversed","title":"reversed = iter.reversed
module-attribute
","text":"An alias of iter.reversed
.
"},{"location":"reference/iters/#iters.iters.Iter","title":"Iter
","text":" Bases: Iterator[T]
Represents iterators.
Source code in iters/iters.py
class Iter(Iterator[T]):\n \"\"\"Represents iterators.\"\"\"\n\n # internals\n\n _iterator: Iterator[T]\n\n def __init__(self, iterable: Iterable[T]) -> None:\n self._iterator = standard_iter(iterable)\n\n def _replace(self, iterator: Iterator[T]) -> None:\n self._iterator = iterator\n\n # implementation\n\n @property\n def iterator(self) -> Iterator[T]:\n \"\"\"The underlying iterator.\"\"\"\n return self._iterator\n\n @classmethod\n def empty(cls) -> Iter[T]:\n \"\"\"Creates an empty iterator.\n\n Example:\n ```python\n >>> iterator = iter.empty()\n >>> iterator.next()\n Null()\n ```\n\n Returns:\n An empty iterator.\n \"\"\"\n return cls.create(empty())\n\n @classmethod\n def of(cls, *items: V) -> Iter[V]:\n \"\"\"Creates an iterator from `items`.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> iterator.next()\n Some(13)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Some(69)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n *items: The items to iterate over.\n\n Returns:\n An iterator over `items`.\n \"\"\"\n return cls.create(items)\n\n @classmethod\n def once(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that yields the `value` exactly once.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Example:\n ```python\n >>> iterator = iter.once(42)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n value: The value to yield.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value`.\n \"\"\"\n return cls.create(once(value))\n\n @classmethod\n def once_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that lazily generates an item exactly once\n by invoking the `function` provided.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Unlike [`once`][iters.iters.Iter.once], this function will\n lazily generate the item on request.\n\n Example:\n ```python\n >>> iterator = iter.once_with(tuple)\n >>> iterator.next()\n Some(())\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with the generated `value`.\n \"\"\"\n return cls.create(once_with(function))\n\n @classmethod\n def repeat(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly repeats a single `value`.\n\n This function repeats a single value over and over again.\n\n Infinite iterators like [`repeat`][iters.iters.Iter.repeat]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n >>> fours = iter.repeat(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> # ad infinitum...\n ```\n\n Arguments:\n value: The value to repeat.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value`.\n \"\"\"\n return cls.create(repeat(value))\n\n @classmethod\n def repeat_exactly(cls, value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that repeats a single `value` exactly `count` times.\n\n This function is a shorthand for [`iter.repeat(value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n # let's only have four fours\n iterator = iter.repeat_exactly(4, 4)\n\n assert iterator.list() == [4, 4, 4, 4]\n ```\n\n Arguments:\n value: The value to repeat.\n count: The number of times to repeat the `value`.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value` repeated `count` times.\n \"\"\"\n return cls.create(repeat(value, count))\n\n @classmethod\n def repeat_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly generates values.\n\n This function repeats generated values over and over again.\n\n Infinite iterators like [`repeat_with`][iters.iters.Iter.repeat_with]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n iterator = iter.repeat_with(tuple)\n\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n\n # ... ad infinitum\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value` of type `V`.\n \"\"\"\n return cls.create(repeat_with(function))\n\n @classmethod\n def repeat_exactly_with(cls, function: Nullary[V], count: int) -> Iter[V]:\n \"\"\"Creates an iterator that generates values of type `V` exactly `count` times.\n\n This function is a shorthand for\n [`iter.repeat_with(function).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n assert iter.repeat_exactly_with(tuple, 3).tuple() == ((), (), ()) # tuple triple!\n ```\n\n Arguments:\n function: The value-generating function to use.\n count: The number of times to repeat values.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with repeated\n `value` of type `V` exactly `count` times.\n \"\"\"\n return cls.create(repeat_with(function, count))\n\n @classmethod\n def count_from_by(cls, start: int, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `start`.\n\n Example:\n ```python\n iterator = iter.count_from_by(1, 2)\n\n assert iterator.next() == 1\n assert iterator.next() == 3\n assert iterator.next() == 5\n assert iterator.next() == 7\n assert iterator.next() == 9\n ```\n\n Arguments:\n start: The value to start from.\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.create(count(start, step))\n\n @classmethod\n def count_from(cls, start: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `start`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(start, 1)\n ```\n\n Arguments:\n start: The value to start from.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(start, DEFAULT_STEP)\n\n @classmethod\n def count_by(cls, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, step)\n ```\n\n Arguments:\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, step)\n\n @classmethod\n def count(cls) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, 1)\n ```\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, DEFAULT_STEP)\n\n @classmethod\n def iterate(cls, function: Unary[V, V], value: V) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls endlessly, i.e. `value`,\n `function(value)`, `function(function(value))`, ...\n\n Example:\n ```python\n zero = 0\n\n def successor(natural: int) -> int:\n return natural + 1\n\n naturals = iter.iterate(successor, zero)\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value))\n\n @classmethod\n def iterate_exactly(cls, function: Unary[V, V], value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls exactly `count` times.\n\n This is a shorthand for\n [`iter.iterate(function, value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n def wrap(item: T) -> List[T]:\n return [item]\n\n iter.iterate_exactly(wrap, 13, 5).list() == [\n 13, [13], [[13]], [[[13]]], [[[[13]]]]\n ]\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n count: The amount of function iterations.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value, count))\n\n @classmethod\n def iter_except(cls, function: Nullary[T], *errors: AnyErrorType) -> Iter[T]:\n \"\"\"Creates an iterator that repeatedly calls `function` until\n any of the `errors` is encountered.\n\n Example:\n An interesting way to reverse arrays:\n\n ```python\n array = [1, 2, 3]\n\n iter.iter_except(array.pop, IndexError).list() == [3, 2, 1]\n ```\n\n Arguments:\n function: The function to iterate.\n *errors: The errors to `except`, stopping iteration.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function results.\n \"\"\"\n return cls.create(iter_except(function, *errors))\n\n @classmethod\n def iter_with(cls, context_manager: ContextManager[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator over the iterable returned by `context_manager`.\n\n This is essentially equivalent to:\n\n ```python\n def iter_with(context_manager: ContextManager[Iterable[T]]) -> Iterator[T]:\n with context_manager as iterable:\n for item in iterable:\n yield item\n\n iterator = iter(iter_with(context_manager))\n ```\n\n This function can be used to open and close files, for example;\n let us consider parsing some file containing integers on every line.\n\n Example:\n ```python\n array = iter.iter_with(open(\"file.in\")).map(int).list()\n ```\n\n Arguments:\n context_manager: The context manager returning an iterable.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over items in an iterable.\n \"\"\"\n return cls.create(iter_with(context_manager))\n\n @classmethod\n def create_chain(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator chaining `iterables` together.\n\n For example, it can be used to chain arrays.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [7, 8, 9]\n\n assert iter.create_chain(a, b, c).list() == a + b + c\n ```\n\n Arguments:\n *iterables: Iterables to chain together.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain(*iterables))\n\n @classmethod\n def create_chain_with(cls, iterable: Iterable[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator chaining iterables in the `iterable` together.\n\n This function essentially flattens the `iterable` provided.\n\n Example:\n ```python\n matrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9],\n ]\n\n result = 45\n\n assert iter.create_chain_with(matrix).sum() == result\n ```\n\n Arguments:\n iterable: The iterable of iterables to chain.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain_from_iterable(iterable))\n\n @classmethod\n def create_combine(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator combining `iterables`.\n\n This method is a slightly different version of\n [`create_interleave_longest`][iters.iters.Iter.create_interleave_longest].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.combine(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to combine.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over combined iterables.\n \"\"\"\n return cls.create(combine(*iterables))\n\n @classmethod\n def create_interleave(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.create_interleave(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave(*iterables))\n\n @classmethod\n def create_interleave_longest(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n This method is a slightly different version of\n [`create_combine`][iters.iters.Iter.create_combine].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6, 7, 8, 9]\n\n assert iter.create_interleave_longest(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave_longest(*iterables))\n\n @overload\n @classmethod\n def create_zip(cls) -> Iter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip(cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]) -> Iter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4, 5)\n\n y = \"nekit\"\n\n iter.create_zip(x, y).list() == [(1, \"n\"), (2, \"e\"), (3, \"k\"), (4, \"i\"), (5, \"t\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip(*iterables))\n\n @overload\n @classmethod\n def create_zip_equal(cls) -> Iter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_equal(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is the strict version of [`create_zip`][iters.iters.Iter.create_zip].\n\n Example:\n ```python\n x = (1, 2, 3)\n\n y = \"dev\"\n\n iter.create_zip_equal(x, y).list() == [(1, \"d\"), (2, \"e\"), (3, \"v\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Raises:\n ValueError: Iterables have different lengths.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_equal(*iterables))\n\n @overload\n @classmethod\n def create_zip_longest(cls) -> Iter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[Option[A]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[Option[A], Option[B]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E], Option[F]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E], Option[F], Option[G],]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[\n Tuple[\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Option[Any]]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_longest(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is a version of [`create_zip`][iters.iters.Iter.create_zip] that places [`None`][None]\n in place of a *j*-th item of an *i*-th tuple when a *j*-th iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4)\n\n y = \"dev\"\n\n f = \"x\"\n\n def process(a: Option[int], b: Option[str]) -> Tuple[int, str]:\n return (a.unwrap_or(0), b.unwrap_or(f))\n\n assert (\n iter.create_zip_longest(x, y)\n .map(unpack_binary(process))\n .list()\n ) == [(1, \"d\"), (2, \"e\"), (3, \"v\"), (4, \"x\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_longest(*iterables))\n\n @overload\n @classmethod\n def create_cartesian_product(cls) -> Iter[EmptyTuple]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_cartesian_product(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Creates an iterator over the\n [*Cartesian product*](https://en.wikipedia.org/wiki/Cartesian_product) of `iterables`.\n\n Warning:\n It only makes sense to compute the product of finite iterables.\n\n Example:\n ```python\n a = (1, 2, 3)\n b = \"xyz\"\n\n c = [\n (1, \"x\"), (1, \"y\"), (1, \"z\"),\n (2, \"x\"), (2, \"y\"), (2, \"z\"),\n (3, \"x\"), (3, \"y\"), (3, \"z\"),\n ]\n\n assert iter.create_cartesian_product(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to compute the Cartesian product of.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over the Cartesian product of iterables.\n \"\"\"\n return cls.create(cartesian_product(*iterables))\n\n @classmethod\n def reversed(cls, reversible: Reversible[T]) -> Iter[T]:\n \"\"\"Creates an iterator over the reversed `reversible`.\n\n Example:\n ```python\n assert iter.reversed([1, 2, 3]).list() == [3, 2, 1]\n ```\n\n Arguments:\n reversible: The reversible to reverse.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over the reversed reversible.\n \"\"\"\n return cls.create(standard_reversed(reversible))\n\n @classmethod\n def function(cls, function: Nullary[T], sentinel: V) -> Iter[T]:\n \"\"\"Creates an iterator over `function` call results until it returns the `sentinel`.\n\n Example:\n ```python\n EMPTY_BYTES = bytes()\n\n READ_BINARY = \"rb\"\n\n CHUNK_SIZE = 65536\n\n def read_chunk(file: BinaryIO) -> Nullary[bytes]:\n def reader(size: int = CHUNK_SIZE) -> bytes:\n return file.read(size)\n\n return reader\n\n with path.open(READ_BINARY) as file:\n iter.function(read_chunk(file), EMPTY_BYTES).for_each(process_chunk)\n ```\n\n Arguments:\n function: The function to iterate.\n sentinel: The sentinel to stop at.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function calls until the `sentinel` is met.\n \"\"\"\n return cls.create(iter_function(function, sentinel))\n\n @classmethod\n def create(cls, iterable: Iterable[U]) -> Iter[U]:\n return cls(iterable) # type: ignore\n\n @classmethod\n def create_tuple(cls, iterables: DynamicTuple[Iterable[U]]) -> DynamicTuple[Iter[U]]:\n return tuple(map(cls, iterables)) # type: ignore\n\n @classmethod\n def create_nested(cls, nested: Iterable[Iterable[U]]) -> Iter[Iter[U]]:\n return cls(map(cls, nested)) # type: ignore\n\n @classmethod\n def create_option(cls, option: Option[Iterable[U]]) -> Option[Iter[U]]:\n return option.map(cls) # type: ignore\n\n def __iter__(self) -> Iter[T]:\n return self\n\n def __next__(self) -> T:\n return next(self.iterator)\n\n def unwrap(self) -> Iterator[T]:\n \"\"\"Unwraps the underlying iterator.\n\n Returns:\n The underlying iterator.\n \"\"\"\n return self.iterator\n\n def iter(self) -> Iter[T]:\n \"\"\"Simply returns `self`.\n\n Returns:\n `self`, the current iterator.\n \"\"\"\n return self\n\n def next(self) -> Option[T]:\n \"\"\"Returns the next item in the iterator.\n\n Example:\n ```python\n value = 42\n\n iterator = iter.once(value)\n\n assert iterator.next().unwrap() is value\n ```\n\n Returns:\n The next item.\n \"\"\"\n return wrap_marked(next(self.iterator, marker))\n\n def compare(self: Iter[ST], other: Iterable[ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable.\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.compare(array).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other)\n\n def compare_by(self, other: Iterable[T], key: Unary[T, ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable using the `key` function.\n\n Example:\n ```python\n array = [13, 34, 42]\n negative = [-x for x in array]\n\n iterator = iter(array)\n\n assert iterator.compare_by(negative, abs).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n key: The key function.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other, key)\n\n def length(self) -> int:\n \"\"\"Computes the length of the iterator.\n\n Example:\n ```python\n assert iter.repeat_exactly(7, 7).length() == 7\n ```\n\n Warning:\n This function exhausts the underlying iterator!\n\n Returns:\n The length of the iterator.\n \"\"\"\n return iter_length(self.iterator)\n\n def first(self) -> Option[T]:\n \"\"\"Returns the first item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.first().unwrap() is value\n ```\n\n Returns:\n The first item.\n \"\"\"\n return wrap_marked(first(self.iterator, marker))\n\n def last(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last(self.iterator, marker))\n\n def last_with_tail(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Note:\n This method uses the [`tail`][iters.utils.tail] function.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last_with_tail().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last_with_tail(self.iterator, marker))\n\n def collect(self, function: Unary[Iterable[T], U]) -> U:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n function(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.collect(list) == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call.\n \"\"\"\n return function(self.iterator)\n\n def collect_iter(self, function: Unary[Iterable[T], Iterable[U]]) -> Iter[U]:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n iterator.create(iterator.collect(function))\n ```\n\n Example:\n ```python\n from typing import TypeVar\n\n T = TypeVar(\"T\")\n\n def identity(item: T) -> T:\n return item\n\n array = [13, 25, 34]\n\n iterator = iter(array).collect_iter(identity)\n\n assert iterator.list() == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call, wrapped back into an iterator.\n \"\"\"\n return self.create(self.collect(function))\n\n def list(self) -> List[T]:\n \"\"\"Collects the iterator into the [`List[T]`][list].\n\n This is equivalent to:\n\n ```python\n list(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.list() == array\n ```\n\n Returns:\n The [`List[T]`][list] over the iterator.\n \"\"\"\n return list(self.iterator)\n\n def set(self: Iter[Q]) -> Set[Q]:\n \"\"\"Collects the iterator into the [`Set[Q]`][set].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n set(iterator.unwrap())\n ```\n\n Example:\n ```python\n set = {13, 42, 69}\n\n iterator = iter(set)\n\n assert iterator.set() == set\n ```\n\n Returns:\n The [`Set[Q]`][set] over the iterator.\n \"\"\"\n return set(self.iterator)\n\n def ordered_set(self: Iter[Q]) -> OrderedSet[Q]:\n \"\"\"Collects the iterator into the [`OrderedSet[Q]`][iters.ordered_set.OrderedSet].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n ordered_set(iterator.unwrap())\n ```\n\n Example:\n ```python\n ordered_set = OrderedSet([13, 42, 69])\n\n iterator = iter(ordered_set)\n\n assert iterator.ordered_set() == ordered_set\n ```\n\n Returns:\n The [`OrderedSet[Q]`][iters.ordered_set.OrderedSet] over the iterator.\n \"\"\"\n return ordered_set(self.iterator)\n\n def tuple(self) -> DynamicTuple[T]:\n \"\"\"Collects the iterator into the [`Tuple[T, ...]`][tuple].\n\n This is equivalent to:\n\n ```python\n tuple(iterator.unwrap())\n ```\n\n Example:\n ```python\n tuple = (-1, 0, 1)\n\n iterator = iter(tuple)\n\n assert iterator.tuple() == tuple\n ```\n\n Returns:\n The [`Tuple[T, ...]`][tuple] over the iterator.\n \"\"\"\n return tuple(self.iterator)\n\n def dict(self: Iter[Tuple[Q, V]]) -> Dict[Q, V]:\n \"\"\"Collects the iterator into the [`Dict[Q, V]`][dict].\n\n Warning:\n The first item in each couple has to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n dict(iterator.unwrap())\n ```\n\n Example:\n ```python\n mapping = {13: \"nekit\", 42: \"dev\"}\n\n iterator = iter(mapping.items())\n\n assert iterator.dict() == mapping\n ```\n\n Returns:\n The [`Dict[Q, V]`][dict] over the iterator.\n \"\"\"\n return dict(self.iterator)\n\n def join(self: Iter[AnyStr], string: AnyStr) -> AnyStr:\n \"\"\"Joins the iterator using the `string`.\n\n Warning:\n The iterator must contain only string items for this method to work.\n\n This is equivalent to:\n\n ```python\n string.join(iterator.unwrap())\n ```\n\n Example:\n ```python\n result = \"melody, nekit\"\n\n string = \", \"\n\n iterator = iter(result.split(string))\n\n assert iterator.join(string) == result\n ```\n\n Returns:\n The joined [`str`][str] or [`bytes`][bytes] depending on the `string` type.\n \"\"\"\n return string.join(self.iterator)\n\n def string(self: Iter[str]) -> str:\n \"\"\"Joins the iterator into the [`str`][str] string.\n\n Warning:\n The iterator must contain only items of type [`str`][str] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_STRING)\n ```\n\n Example:\n ```python\n strings = (\"x\", \"y\", \"z\")\n string = \"xyz\"\n\n iterator = iter(strings)\n\n assert iterator.string() == string\n ```\n\n Returns:\n The joined [`str`][str] string.\n \"\"\"\n return self.join(EMPTY_STRING)\n\n def bytes(self: Iter[bytes]) -> bytes:\n \"\"\"Joins the iterator into the [`bytes`][bytes] string.\n\n Warning:\n The iterator must contain only items of type [`bytes`][bytes] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_BYTES)\n ```\n\n Returns:\n The joined [`bytes`][bytes] string.\n \"\"\"\n return self.join(EMPTY_BYTES)\n\n def count_dict(self: Iter[Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n Example:\n ```python\n bits = (0, 1, 1, 0, 1, 1, 1, 0)\n\n result = [(1, 5), (0, 3)]\n\n iterator = iter(bits)\n\n assert iterator.count_dict().most_common() == result\n ```\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the items of the iterator.\n \"\"\"\n return count_dict(self.iterator)\n\n def count_dict_by(self, key: Unary[T, Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter]\n by applying the `key` function.\n\n Example:\n ```python\n sets = [{}, {0}, {1}, {0, 1}]\n\n iterator = iter(sets)\n\n result = [(1, 2), (2, 1), (0, 1)]\n\n assert iterator.count_dict_by(len).most_common() == result\n ```\n\n Arguments:\n key: The key function.\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the keys\n corresponding to the items of the iterator.\n \"\"\"\n return count_dict(self.iterator, key)\n\n def group_dict(self: Iter[Q]) -> Dict[Q, List[Q]]:\n return group_dict(self.iterator)\n\n def group_dict_by(self, key: Unary[T, Q]) -> Dict[Q, List[T]]:\n return group_dict(self.iterator, key)\n\n def group(self) -> Iter[Tuple[T, Iter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n for group_key, group_iterator in group(self.iterator)\n )\n\n def group_by(self, key: Unary[T, U]) -> Iter[Tuple[U, Iter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n for group_key, group_iterator in group(self.iterator, key)\n )\n\n def group_list(self) -> Iter[Tuple[T, List[T]]]:\n return self.create(group_list(self.iterator))\n\n def group_list_by(self, key: Unary[T, U]) -> Iter[Tuple[U, List[T]]]:\n return self.create(group_list(self.iterator, key))\n\n def all(self) -> bool:\n return all(self.iterator)\n\n def all_by(self, predicate: Predicate[T]) -> bool:\n return self.map(predicate).all()\n\n def any(self) -> bool:\n return any(self.iterator)\n\n def any_by(self, predicate: Predicate[T]) -> bool:\n return self.map(predicate).any()\n\n def all_equal(self) -> bool:\n return all_equal(self.iterator)\n\n def all_equal_by(self, key: Unary[T, U]) -> bool:\n return all_equal(self.iterator, key)\n\n def all_unique(self) -> bool:\n return all_unique(self.iterator)\n\n def all_unique_by(self, key: Unary[T, U]) -> bool:\n return all_unique(self.iterator, key)\n\n def all_unique_fast(self: Iter[Q]) -> bool:\n return all_unique_fast(self.iterator)\n\n def all_unique_fast_by(self, key: Unary[T, Q]) -> bool:\n return all_unique_fast(self.iterator, key)\n\n def remove(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(remove(predicate, self.iterator))\n\n def remove_duplicates(self) -> Iter[T]:\n return self.create(remove_duplicates(self.iterator))\n\n def remove_duplicates_by(self, key: Unary[T, U]) -> Iter[T]:\n return self.create(remove_duplicates(self.iterator, key))\n\n def filter(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(filter(predicate, self.iterator))\n\n def filter_false(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(filter_false(predicate, self.iterator))\n\n def filter_except(self, validate: Unary[T, Any], *errors: AnyErrorType) -> Iter[T]:\n return self.create(filter_except(validate, self.iterator, *errors))\n\n def compress(self, selectors: Selectors) -> Iter[T]:\n return self.create(compress(self.iterator, selectors))\n\n def position_all(self, predicate: Optional[Predicate[T]]) -> Iter[int]:\n return self.create(position_all(predicate, self.iterator))\n\n def position(self, predicate: Optional[Predicate[T]]) -> Option[int]:\n return wrap_marked(position(predicate, self.iterator, marker))\n\n def find_all(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(find_all(predicate, self.iterator))\n\n def find(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(find(predicate, self.iterator, marker)) # type: ignore # weird\n\n def find_or_first(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(find_or_first(predicate, self.iterator, marker)) # type: ignore # weird\n\n def find_or_last(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(find_or_last(predicate, self.iterator, marker)) # type: ignore # weird\n\n def contains(self, item: V) -> bool:\n return contains(item, self.iterator)\n\n def contains_identity(self: Iter[V], item: V) -> bool:\n return contains_identity(item, self.iterator)\n\n def reduce(self, function: Binary[T, T, T]) -> T:\n return reduce(function, self.iterator)\n\n def fold(self, initial: V, function: Binary[V, T, V]) -> V:\n return fold(initial, function, self.iterator)\n\n @early_option\n def sum(self: Iter[S]) -> Option[S]:\n return Some(self.sum_with(self.next().early()))\n\n def sum_with(self: Iter[S], initial: S) -> S:\n return sum(self.iterator, initial)\n\n @early_option\n def product(self: Iter[P]) -> Option[P]:\n return Some(self.product_with(self.next().early()))\n\n def product_with(self: Iter[P], initial: P) -> P:\n return product(self.iterator, initial)\n\n def accumulate_reduce(self, function: Binary[T, T, T]) -> Iter[T]:\n return self.create(accumulate_reduce(function, self.iterator))\n\n def accumulate_fold(self, initial: V, function: Binary[V, T, V]) -> Iter[V]:\n return self.create(accumulate_fold(initial, function, self.iterator))\n\n def accumulate_sum(self: Iter[S]) -> Iter[S]:\n return self.create(accumulate_sum(self.iterator))\n\n def accumulate_sum_with(self: Iter[S], initial: S) -> Iter[S]:\n return self.create(accumulate_sum(self.iterator, initial))\n\n def accumulate_product(self: Iter[P]) -> Iter[P]:\n return self.create(accumulate_product(self.iterator))\n\n def accumulate_product_with(self: Iter[P], initial: P) -> Iter[P]:\n return self.create(accumulate_product(self.iterator, initial))\n\n def min(self: Iter[ST]) -> Option[ST]:\n return wrap_marked(min(self.iterator, default=marker))\n\n def min_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(min(self.iterator, key=key, default=marker)) # type: ignore # weird\n\n def max(self: Iter[ST]) -> Option[ST]:\n return wrap_marked(max(self.iterator, default=marker))\n\n def max_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(max(self.iterator, key=key, default=marker)) # type: ignore # weird\n\n def min_max(self: Iter[ST]) -> Option[Pair[ST]]:\n return wrap_marked(min_max(self.iterator, default=marker))\n\n def min_max_by(self, key: Unary[T, ST]) -> Option[Pair[T]]:\n return wrap_marked(min_max(self.iterator, key=key, default=marker))\n\n def map(self, function: Unary[T, U]) -> Iter[U]:\n return self.create(map(function, self.iterator))\n\n def map_except(self, function: Unary[T, U], *errors: AnyErrorType) -> Iter[U]:\n return self.create(map_except(function, self.iterator, *errors))\n\n def flat_map(self, function: Unary[T, Iterable[U]]) -> Iter[U]:\n return self.create(flat_map(function, self.iterator))\n\n def filter_map(self, predicate: Optional[Predicate[T]], function: Unary[T, U]) -> Iter[U]:\n return self.create(filter_map(predicate, function, self.iterator))\n\n def filter_false_map(self, predicate: Optional[Predicate[T]], function: Unary[T, U]) -> Iter[U]:\n return self.create(filter_false_map(predicate, function, self.iterator))\n\n def flatten(self: Iter[Iterable[U]]) -> Iter[U]:\n return self.create(flatten(self.iterator))\n\n def collapse(self: Iter[RecursiveIterable[U]]) -> Iter[U]:\n return self.create(collapse(self.iterator))\n\n def enumerate(self) -> Iter[Tuple[int, T]]:\n return self.create(enumerate(self.iterator))\n\n def enumerate_from(self, start: int) -> Iter[Tuple[int, T]]:\n return self.create(enumerate(self.iterator, start))\n\n def consume(self) -> None:\n consume(self.iterator)\n\n def for_each(self, function: Unary[T, Any]) -> None:\n for_each(function, self.iterator)\n\n def append(self: Iter[V], item: V) -> Iter[V]:\n return self.create(append(item, self.iterator))\n\n def prepend(self: Iter[V], item: V) -> Iter[V]:\n return self.create(prepend(item, self.iterator))\n\n def at(self, index: int) -> Option[T]:\n return wrap_marked(at(index, self.iterator, marker))\n\n def at_or_last(self, index: int) -> Option[T]:\n return wrap_marked(at_or_last(index, self.iterator, marker))\n\n @overload\n def slice(self, __stop: Optional[int]) -> Iter[T]:\n ...\n\n @overload\n def slice(\n self, __start: Optional[int], __stop: Optional[int], __step: Optional[int] = ...\n ) -> Iter[T]:\n ...\n\n def slice(self, *slice_args: Optional[int]) -> Iter[T]:\n return self.create(iter_slice(self.iterator, *slice_args))\n\n def drop(self, size: int) -> Iter[T]:\n return self.create(drop(size, self.iterator))\n\n skip = drop\n\n def rest(self) -> Iter[T]:\n return self.create(rest(self.iterator))\n\n def drop_while(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(drop_while(predicate, self.iterator))\n\n skip_while = drop_while\n\n def take(self, size: int) -> Iter[T]:\n return self.create(take(size, self.iterator))\n\n def take_while(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(take_while(predicate, self.iterator))\n\n def step_by(self, step: int) -> Iter[T]:\n return self.create(step_by(step, self.iterator))\n\n def tail(self, size: int) -> Iter[T]:\n return self.create(tail(size, self.iterator))\n\n def apply_chain(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(chain(self.iterator, *iterables))\n\n chain = mixed_method(create_chain, apply_chain)\n\n def apply_chain_with(self, iterables: Iterable[Iterable[T]]) -> Iter[T]:\n return self.chain(chain_from_iterable(iterables))\n\n chain_with = mixed_method(create_chain_with, apply_chain_with)\n\n def cycle(self) -> Iter[T]:\n return self.create(cycle(self.iterator))\n\n def intersperse(self: Iter[V], value: V) -> Iter[V]:\n return self.create(intersperse(value, self.iterator))\n\n def intersperse_with(self, function: Nullary[T]) -> Iter[T]:\n return self.create(intersperse_with(function, self.iterator))\n\n def apply_interleave(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(interleave(self.iterator, *iterables))\n\n interleave = mixed_method(create_interleave, apply_interleave)\n\n def apply_interleave_longest(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(interleave_longest(self.iterator, *iterables))\n\n interleave_longest = mixed_method(create_interleave_longest, apply_interleave_longest)\n\n def apply_combine(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(combine(self.iterator, *iterables))\n\n combine = mixed_method(create_combine, apply_combine)\n\n @overload\n def distribute_unsafe(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[1]) -> Tuple1[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[2]) -> Tuple2[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[3]) -> Tuple3[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[4]) -> Tuple4[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[5]) -> Tuple5[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[6]) -> Tuple6[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[7]) -> Tuple7[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[8]) -> Tuple8[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: int) -> DynamicTuple[Iter[T]]:\n ...\n\n def distribute_unsafe(self, count: int) -> DynamicTuple[Iter[T]]:\n return self.create_tuple(distribute_unsafe(count, self.iterator))\n\n distribute_infinite = distribute_unsafe\n\n @overload\n def distribute(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute(self, count: Literal[1]) -> Tuple1[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[2]) -> Tuple2[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[3]) -> Tuple3[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[4]) -> Tuple4[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[5]) -> Tuple5[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[6]) -> Tuple6[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[7]) -> Tuple7[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[8]) -> Tuple8[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: int) -> DynamicTuple[Iter[T]]:\n ...\n\n def distribute(self, count: int) -> DynamicTuple[Iter[T]]:\n return self.create_tuple(distribute(count, self.iterator))\n\n def divide(self, count: int) -> Iter[Iter[T]]:\n return self.create_nested(divide(count, self.iterator))\n\n def pad(self: Iter[V], value: V) -> Iter[V]:\n return self.create(pad(value, self.iterator))\n\n def pad_exactly(self: Iter[V], value: V, size: int) -> Iter[V]:\n return self.create(pad(value, self.iterator, size))\n\n def pad_multiple(self: Iter[V], value: V, size: int) -> Iter[V]:\n return self.create(pad(value, self.iterator, size, multiple=True))\n\n def pad_with(self: Iter[V], function: Unary[int, V]) -> Iter[V]:\n return self.create(pad_with(function, self.iterator))\n\n def pad_exactly_with(self: Iter[V], function: Unary[int, V], size: int) -> Iter[V]:\n return self.create(pad_with(function, self.iterator, size))\n\n def pad_multiple_with(self: Iter[V], function: Unary[int, V], size: int) -> Iter[V]:\n return self.create(pad_with(function, self.iterator, size, multiple=True))\n\n def chunks(self, size: int) -> Iter[List[T]]:\n return self.create(chunks(size, self.iterator))\n\n def iter_chunks(self, size: int) -> Iter[Iter[T]]:\n return self.create_nested(iter_chunks(size, self.iterator))\n\n def iter_chunks_unsafe(self, size: int) -> Iter[Iter[T]]:\n return self.create_nested(iter_chunks_unsafe(size, self.iterator))\n\n iter_chunks_infinite = iter_chunks_unsafe\n\n @overload\n def groups(self, size: Literal[0]) -> Iter[Never]:\n ...\n\n @overload\n def groups(self, size: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def groups(self, size: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def groups(self, size: int) -> Iter[DynamicTuple[T]]:\n return self.create(groups(size, self.iterator))\n\n @overload\n def groups_longest(self, size: Literal[0]) -> Iter[Never]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[1]) -> Iter[Tuple1[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[2]) -> Iter[Tuple2[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[3]) -> Iter[Tuple3[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[4]) -> Iter[Tuple4[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[5]) -> Iter[Tuple5[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[6]) -> Iter[Tuple6[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[7]) -> Iter[Tuple7[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[8]) -> Iter[Tuple8[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: int) -> Iter[DynamicTuple[Option[T]]]:\n ...\n\n def groups_longest(self, size: int) -> Iter[DynamicTuple[Option[T]]]:\n return self.create(groups_longest(size, self.iterator))\n\n def pairs(self) -> Iter[Pair[T]]:\n return self.create(pairs(self.iterator))\n\n def pairs_longest(self) -> Iter[Pair[Option[T]]]:\n return self.create(pairs_longest(self.iterator))\n\n def iter_windows(self, size: int) -> Iter[Iter[T]]:\n return self.create_nested(iter_windows(size, self.iterator))\n\n def list_windows(self, size: int) -> Iter[List[T]]:\n return self.create(list_windows(size, self.iterator))\n\n def pairs_windows(self) -> Iter[Pair[T]]:\n return self.create(pairs_windows(self.iterator))\n\n @overload\n def tuple_windows(self, size: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def tuple_windows(self, size: int) -> Iter[DynamicTuple[T]]:\n return self.create(tuple_windows(size, self.iterator))\n\n def set_windows(self: Iter[Q], size: int) -> Iter[Set[Q]]:\n return self.create(set_windows(size, self.iterator))\n\n @overload\n def apply_zip(self) -> Iter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip(self, __iterable_a: Iterable[A]) -> Iter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n def apply_zip(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n return self.create(zip(self.iterator, *iterables))\n\n zip = mixed_method(create_zip, apply_zip)\n\n @overload\n def apply_zip_equal(self) -> Iter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip_equal(self, __iterable_a: Iterable[A]) -> Iter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip_equal(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip_equal(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip_equal( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n def apply_zip_equal(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n return self.create(zip_equal(self.iterator, *iterables))\n\n zip_equal = mixed_method(create_zip_equal, apply_zip_equal)\n\n @overload\n def apply_zip_longest(self) -> Iter[Tuple[Option[T]]]:\n ...\n\n @overload\n def apply_zip_longest(self, __iterable_a: Iterable[A]) -> Iter[Tuple[Option[T], Option[A]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[Option[T], Option[A], Option[B]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D], Option[E], Option[F],]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Option[Any]]]:\n ...\n\n def apply_zip_longest(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]:\n return self.create(zip_longest(self.iterator, *iterables))\n\n zip_longest = mixed_method(create_zip_longest, apply_zip_longest)\n\n def transpose(self: Iter[Iterable[U]]) -> Iter[DynamicTuple[U]]:\n return self.create(transpose(self.iterator))\n\n @overload\n def apply_cartesian_product(self) -> Iter[Tuple[T]]:\n ...\n\n @overload\n def apply_cartesian_product(self, __iterable_a: Iterable[A]) -> Iter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_cartesian_product( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n def apply_cartesian_product(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n return self.create(cartesian_product(self.iterator, *iterables))\n\n cartesian_product = mixed_method(create_cartesian_product, apply_cartesian_product)\n\n @overload\n def cartesian_power(self, power: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n def cartesian_power(self, power: int) -> Iter[DynamicTuple[T]]:\n \"\"\"Creates an iterator over the\n [*Cartesian power*](https://en.wikipedia.org/wiki/Cartesian_product) of the iterator.\n\n Warning:\n It only makes sense to compute the Cartesian power of finite iterators.\n\n Example:\n ```python\n bits = (0, 1)\n result = ((0, 0), (0, 1), (1, 0), (1, 1))\n\n iterator = iter(bits)\n\n assert iterator.cartesian_power(2).tuple() == result\n ```\n\n Arguments:\n power: The power to \"raise\" the iterator to.\n\n Returns:\n An [`Iter[Tuple[...]]`] over the Cartesian power of the iterator.\n \"\"\"\n return self.create(cartesian_power(power, self.iterator))\n\n @overload\n def combinations(self, count: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def combinations(self, count: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def combinations(self, count: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def combinations(self, count: int) -> Iter[DynamicTuple[T]]:\n return self.create(combinations(count, self.iterator))\n\n @overload\n def combinations_with_replacement(self, count: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def combinations_with_replacement(self, count: int) -> Iter[DynamicTuple[T]]:\n return self.create(combinations_with_replacement(count, self.iterator))\n\n def permute(self) -> Iter[DynamicTuple[T]]:\n return self.create(permute(self.iterator))\n\n @overload\n def permutations(self, count: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def permutations(self, count: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def permutations(self, count: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def permutations(self, count: int) -> Iter[DynamicTuple[T]]:\n return self.create(permutations(count, self.iterator))\n\n def power_set(self) -> Iter[DynamicTuple[T]]:\n \"\"\"Computes the power set of the iterator.\n\n The power set of $S$ contains all subsets of $S$, including\n the empty set $\\\\varnothing$ and $S$ itself.\n The power set is often denoted as $2^S$ since if $|S| = n$, then $|2^S| = 2^n$.\n\n Returns:\n An iterator over the power set of the iterator.\n \"\"\"\n return self.create(power_set(self.iterator))\n\n def reverse(self) -> Iter[T]:\n return self.create(reverse(self.iterator))\n\n def sorted(self: Iter[ST]) -> List[ST]:\n return sorted(self.iterator)\n\n def sorted_by(self, key: Unary[T, ST]) -> List[T]:\n return sorted(self.iterator, key=key)\n\n def sorted_reverse(self: Iter[ST]) -> List[ST]:\n return sorted(self.iterator, reverse=True)\n\n def sorted_reverse_by(self, key: Unary[T, ST]) -> List[T]:\n return sorted(self.iterator, key=key, reverse=True)\n\n def sort(self: Iter[ST]) -> Iter[ST]:\n return self.create(sort(self.iterator))\n\n def sort_by(self, key: Unary[T, ST]) -> Iter[T]:\n return self.create(sort(self.iterator, key=key))\n\n def sort_reverse(self: Iter[ST]) -> Iter[ST]:\n return self.create(sort(self.iterator, reverse=True))\n\n def sort_reverse_by(self, key: Unary[T, ST]) -> Iter[T]:\n return self.create(sort(self.iterator, key=key, reverse=True))\n\n def is_sorted(self: Iter[LT]) -> bool:\n return is_sorted(self.iterator)\n\n def is_sorted_by(self, key: Unary[T, LT]) -> bool:\n return is_sorted(self.iterator, key)\n\n def is_sorted_reverse(self: Iter[LT]) -> bool:\n return is_sorted(self.iterator, reverse=True)\n\n def is_sorted_reverse_by(self, key: Unary[T, LT]) -> bool:\n return is_sorted(self.iterator, key, reverse=True)\n\n def is_sorted_strict(self: Iter[ST]) -> bool:\n return is_sorted(self.iterator, strict=True)\n\n def is_sorted_strict_by(self, key: Unary[T, ST]) -> bool:\n return is_sorted(self.iterator, key, strict=True)\n\n def is_sorted_reverse_strict(self: Iter[ST]) -> bool:\n return is_sorted(self.iterator, strict=True, reverse=True)\n\n def is_sorted_reverse_strict_by(self, key: Unary[T, ST]) -> bool:\n return is_sorted(self.iterator, key, strict=True, reverse=True)\n\n def duplicates_fast(self: Iter[Q]) -> Iter[Q]:\n return self.create(duplicates_fast(self.iterator))\n\n def duplicates_fast_by(self, key: Unary[T, Q]) -> Iter[T]:\n return self.create(duplicates_fast(self.iterator, key))\n\n def duplicates(self) -> Iter[T]:\n return self.create(duplicates(self.iterator))\n\n def duplicates_by(self, key: Unary[T, V]) -> Iter[T]:\n return self.create(duplicates(self.iterator, key))\n\n def unique_fast(self: Iter[Q]) -> Iter[Q]:\n return self.create(unique_fast(self.iterator))\n\n def unique_fast_by(self, key: Unary[T, Q]) -> Iter[T]:\n return self.create(unique_fast(self.iterator, key))\n\n def unique(self) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator.\n\n This function may be slower than [`unique_fast`][iters.iters.Iter.unique_fast]\n in case `T` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, 1, 0, 1, 1, 1, 0)\n >>> iterator.unique().tuple()\n (0, 1)\n ```\n\n Returns:\n An iterator over the unique items in the iterator.\n \"\"\"\n return self.create(unique(self.iterator))\n\n def unique_by(self, key: Unary[T, V]) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator based on the given `key`.\n\n This function may be slower than [`unique_fast_by`][iters.iters.Iter.unique_fast_by]\n in case `V` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, -1)\n >>> iterator.unique_by(abs).tuple()\n (0, 1)\n ```\n\n Arguments:\n key: The key to use in determining uniqueness.\n\n Returns:\n An iterator over the unique items in the iterator based on the given `key`.\n \"\"\"\n return self.create(unique(self.iterator, key))\n\n def partition(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *safely* based on the given `predicate`,\n loading **all** items into memory!\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_positive(z: int) -> bool:\n return z > 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> positive, non_positive = iterator.partition(is_positive)\n >>> positive.list()\n [1]\n >>> non_positive.list()\n [-1, 0]\n ```\n\n Note:\n This method exhausts the underlying iterator.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n def partition_unsafe(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *unsafely* based on the given `predicate`.\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_negative(z: int) -> bool:\n return z < 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> negative, non_negative = iterator.partition_unsafe(is_negative)\n >>> non_negative.list()\n [0, 1]\n >>> negative.list()\n [-1]\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method works on the underlying iterator, so using the original iterator\n is not recommended after calling this method.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition_unsafe(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n partition_infinite = partition_unsafe\n \"\"\"An alias of [`partition_unsafe`][iters.iters.Iter.partition_unsafe],\n since partitioning infinite iterators can only be done *unsafely*.\n \"\"\"\n\n def copy(self) -> Iter[T]:\n \"\"\"Copies the iterator *safely*, loading **all** items into memory!\n\n Example:\n ```python\n >>> iterator = iter.of(1, 2, 3)\n >>> copy = iterator.copy()\n >>> iterator.tuple()\n (1, 2, 3)\n >>> copy.tuple()\n (1, 2, 3)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n\n def copy_unsafe(self) -> Iter[T]:\n \"\"\"Copies the iterator *unsafely*.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> copy = iterator.copy_unsafe()\n >>> iterator.zip(copy).tuple()\n ((13, 13), (42, 42), (69, 69))\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy_unsafe(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n\n copy_infinite = copy_unsafe\n \"\"\"An alias of [`copy_unsafe`][iters.iters.Iter.copy_unsafe],\n since copying infinite iterators can only be done *unsafely*.\n \"\"\"\n\n def spy(self, size: int) -> List[T]:\n \"\"\"Spies on at most `size` next items of the iterator, without consuming them.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.spy(2)\n [13, 34]\n >>> iterator.spy(4)\n [13, 34, 42]\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Arguments:\n size: The amount of items to spy on.\n\n Returns:\n Up to `size` next items of the iterator.\n \"\"\"\n result, iterator = spy(size, self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def peek(self) -> Option[T]:\n \"\"\"Peeks at the next item in the iterator, without consuming it.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.peek()\n Some(13)\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n The next item in the iterator, if one exists.\n \"\"\"\n item, iterator = peek(self.iterator, marker)\n\n self._replace(iterator)\n\n return wrap_marked(item)\n\n def has_next(self) -> bool:\n \"\"\"Checks if the iterator has a next item (i.e. is non-empty).\n\n Example:\n ```python\n >>> assert iter.once(1).has_next()\n >>> assert not iter.empty().has_next()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator has a next item.\n \"\"\"\n result, iterator = has_next(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def is_empty(self) -> bool:\n \"\"\"Checks if the iterator is empty.\n\n Example:\n ```python\n >>> assert iter.empty().is_empty()\n >>> assert not iter.once(0).is_empty()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator is empty.\n \"\"\"\n result, iterator = is_empty(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def repeat_last(self) -> Iter[T]:\n \"\"\"Repeats the last item of the iterator indefinitely.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1)\n >>> iterator.next()\n Some(0)\n >>> iterator.next()\n Some(1)\n >>> iterator.next()\n Some(1) # now repeating the last item\n ```\n\n Returns:\n The iterator with the last item repeated indefinitely.\n \"\"\"\n return self.create(repeat_last(self.iterator))\n\n def repeat_each(self, count: int) -> Iter[T]:\n \"\"\"Repeat each item of the iterator `count` times.\n\n Example:\n ```python\n >>> iter.of(0, 1).repeat_each(2).tuple()\n (0, 0, 1, 1)\n ```\n\n ```python\n >>> iter.once(0).repeat_each(0).tuple()\n ()\n ```\n\n Arguments:\n count: The amount of times to repeat each item.\n\n Returns:\n The iterator with each item repeated `count` times.\n \"\"\"\n return self.create(repeat_each(count, self.iterator))\n\n def inspect(self, function: Inspect[T]) -> Iter[T]:\n \"\"\"Inspects each item of the iterator with the given `function`.\n\n Example:\n ```python\n >>> iter.of(1, 2, 3).inspect(print).consume()\n 1\n 2\n 3\n ```\n\n Arguments:\n function: The inspecting function.\n\n Returns:\n The original iterator.\n \"\"\"\n return self.create(inspect(function, self.iterator))\n\n def scan(self, state: V, function: Binary[V, T, Option[U]]) -> Iter[U]:\n return self.create(scan(state, function, self.iterator))\n\n def filter_map_option(self, function: Unary[T, Option[U]]) -> Iter[U]:\n return self.create(filter_map_option(function, self.iterator))\n\n # def transpose_option(self: Iter[Option[U]]) -> Option[Iter[U]]:\n # return self.create_option(transpose_option(self.iterator))\n\n def into_async_iter(self) -> AsyncIter[T]:\n \"\"\"Converts an [`Iter[T]`][iters.iters.Iter] into\n an [`AsyncIter[T]`][iters.async_iters.AsyncIter].\n\n Example:\n ```python\n >>> async_iterator = iter.of(13, 34, 42).into_async_iter()\n >>> await async_iterator.tuple()\n (13, 34, 42)\n ```\n\n Returns:\n The async iterator created from the iterator.\n \"\"\"\n return async_iter(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.iterator","title":"iterator: Iterator[T]
property
","text":"The underlying iterator.
"},{"location":"reference/iters/#iters.iters.Iter.partition_infinite","title":"partition_infinite = partition_unsafe
class-attribute
instance-attribute
","text":"An alias of partition_unsafe
, since partitioning infinite iterators can only be done unsafely.
"},{"location":"reference/iters/#iters.iters.Iter.copy_infinite","title":"copy_infinite = copy_unsafe
class-attribute
instance-attribute
","text":"An alias of copy_unsafe
, since copying infinite iterators can only be done unsafely.
"},{"location":"reference/iters/#iters.iters.Iter.empty","title":"empty() -> Iter[T]
classmethod
","text":"Creates an empty iterator.
Example >>> iterator = iter.empty()\n>>> iterator.next()\nNull()\n
Returns:
Type Description Iter[T]
An empty iterator.
Source code in iters/iters.py
@classmethod\ndef empty(cls) -> Iter[T]:\n \"\"\"Creates an empty iterator.\n\n Example:\n ```python\n >>> iterator = iter.empty()\n >>> iterator.next()\n Null()\n ```\n\n Returns:\n An empty iterator.\n \"\"\"\n return cls.create(empty())\n
"},{"location":"reference/iters/#iters.iters.Iter.of","title":"of(*items: V) -> Iter[V]
classmethod
","text":"Creates an iterator from items
.
Example >>> iterator = iter.of(13, 42, 69)\n>>> iterator.next()\nSome(13)\n>>> iterator.next()\nSome(42)\n>>> iterator.next()\nSome(69)\n>>> iterator.next()\nNull()\n
Parameters:
Name Type Description Default *items
V
The items to iterate over.
()
Returns:
Type Description Iter[V]
An iterator over items
.
Source code in iters/iters.py
@classmethod\ndef of(cls, *items: V) -> Iter[V]:\n \"\"\"Creates an iterator from `items`.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> iterator.next()\n Some(13)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Some(69)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n *items: The items to iterate over.\n\n Returns:\n An iterator over `items`.\n \"\"\"\n return cls.create(items)\n
"},{"location":"reference/iters/#iters.iters.Iter.once","title":"once(value: V) -> Iter[V]
classmethod
","text":"Creates an iterator that yields the value
exactly once.
This is commonly used to adapt a single value into a chain
of other kinds of iteration. Maybe you have an iterator that covers almost everything, but you need an extra special case. Maybe you have a function which works on iterators, but you only need to process one value.
Example >>> iterator = iter.once(42)\n>>> iterator.next()\nSome(42)\n>>> iterator.next()\nNull()\n
Parameters:
Name Type Description Default value
V
The value to yield.
required Returns:
Type Description Iter[V]
An Iter[V]
with value
.
Source code in iters/iters.py
@classmethod\ndef once(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that yields the `value` exactly once.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Example:\n ```python\n >>> iterator = iter.once(42)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n value: The value to yield.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value`.\n \"\"\"\n return cls.create(once(value))\n
"},{"location":"reference/iters/#iters.iters.Iter.once_with","title":"once_with(function: Nullary[V]) -> Iter[V]
classmethod
","text":"Creates an iterator that lazily generates an item exactly once by invoking the function
provided.
This is commonly used to adapt a single value into a chain
of other kinds of iteration. Maybe you have an iterator that covers almost everything, but you need an extra special case. Maybe you have a function which works on iterators, but you only need to process one value.
Unlike once
, this function will lazily generate the item on request.
Example >>> iterator = iter.once_with(tuple)\n>>> iterator.next()\nSome(())\n>>> iterator.next()\nNull()\n
Parameters:
Name Type Description Default function
Nullary[V]
The value-generating function to use.
required Returns:
Type Description Iter[V]
An Iter[V]
with the generated value
.
Source code in iters/iters.py
@classmethod\ndef once_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that lazily generates an item exactly once\n by invoking the `function` provided.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Unlike [`once`][iters.iters.Iter.once], this function will\n lazily generate the item on request.\n\n Example:\n ```python\n >>> iterator = iter.once_with(tuple)\n >>> iterator.next()\n Some(())\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with the generated `value`.\n \"\"\"\n return cls.create(once_with(function))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat","title":"repeat(value: V) -> Iter[V]
classmethod
","text":"Creates an iterator that endlessly repeats a single value
.
This function repeats a single value over and over again.
Infinite iterators like repeat
are often used with adapters like take
, in order to make them finite.
Example >>> fours = iter.repeat(4)\n>>> fours.next()\nSome(4)\n>>> fours.next()\nSome(4)\n>>> fours.next()\nSome(4)\n>>> # ad infinitum...\n
Parameters:
Name Type Description Default value
V
The value to repeat.
required Returns:
Type Description Iter[V]
An infinite Iter[V]
with repeated value
.
Source code in iters/iters.py
@classmethod\ndef repeat(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly repeats a single `value`.\n\n This function repeats a single value over and over again.\n\n Infinite iterators like [`repeat`][iters.iters.Iter.repeat]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n >>> fours = iter.repeat(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> # ad infinitum...\n ```\n\n Arguments:\n value: The value to repeat.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value`.\n \"\"\"\n return cls.create(repeat(value))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_exactly","title":"repeat_exactly(value: V, count: int) -> Iter[V]
classmethod
","text":"Creates an iterator that repeats a single value
exactly count
times.
This function is a shorthand for iter.repeat(value).take(count)
.
Example # let's only have four fours\niterator = iter.repeat_exactly(4, 4)\n\nassert iterator.list() == [4, 4, 4, 4]\n
Parameters:
Name Type Description Default value
V
The value to repeat.
required count
int
The number of times to repeat the value
.
required Returns:
Type Description Iter[V]
An Iter[V]
with value
repeated count
times.
Source code in iters/iters.py
@classmethod\ndef repeat_exactly(cls, value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that repeats a single `value` exactly `count` times.\n\n This function is a shorthand for [`iter.repeat(value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n # let's only have four fours\n iterator = iter.repeat_exactly(4, 4)\n\n assert iterator.list() == [4, 4, 4, 4]\n ```\n\n Arguments:\n value: The value to repeat.\n count: The number of times to repeat the `value`.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value` repeated `count` times.\n \"\"\"\n return cls.create(repeat(value, count))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_with","title":"repeat_with(function: Nullary[V]) -> Iter[V]
classmethod
","text":"Creates an iterator that endlessly generates values.
This function repeats generated values over and over again.
Infinite iterators like repeat_with
are often used with adapters like take
, in order to make them finite.
Example iterator = iter.repeat_with(tuple)\n\nassert iterator.next().unwrap() == ()\nassert iterator.next().unwrap() == ()\nassert iterator.next().unwrap() == ()\n\n# ... ad infinitum\n
Parameters:
Name Type Description Default function
Nullary[V]
The value-generating function to use.
required Returns:
Type Description Iter[V]
An infinite Iter[V]
with repeated value
of type V
.
Source code in iters/iters.py
@classmethod\ndef repeat_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly generates values.\n\n This function repeats generated values over and over again.\n\n Infinite iterators like [`repeat_with`][iters.iters.Iter.repeat_with]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n iterator = iter.repeat_with(tuple)\n\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n\n # ... ad infinitum\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value` of type `V`.\n \"\"\"\n return cls.create(repeat_with(function))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_exactly_with","title":"repeat_exactly_with(function: Nullary[V], count: int) -> Iter[V]
classmethod
","text":"Creates an iterator that generates values of type V
exactly count
times.
This function is a shorthand for iter.repeat_with(function).take(count)
.
Example assert iter.repeat_exactly_with(tuple, 3).tuple() == ((), (), ()) # tuple triple!\n
Parameters:
Name Type Description Default function
Nullary[V]
The value-generating function to use.
required count
int
The number of times to repeat values.
required Returns:
Type Description Iter[V]
An Iter[V]
with repeated value
of type V
exactly count
times.
Source code in iters/iters.py
@classmethod\ndef repeat_exactly_with(cls, function: Nullary[V], count: int) -> Iter[V]:\n \"\"\"Creates an iterator that generates values of type `V` exactly `count` times.\n\n This function is a shorthand for\n [`iter.repeat_with(function).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n assert iter.repeat_exactly_with(tuple, 3).tuple() == ((), (), ()) # tuple triple!\n ```\n\n Arguments:\n function: The value-generating function to use.\n count: The number of times to repeat values.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with repeated\n `value` of type `V` exactly `count` times.\n \"\"\"\n return cls.create(repeat_with(function, count))\n
"},{"location":"reference/iters/#iters.iters.Iter.count_from_by","title":"count_from_by(start: int, step: int) -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by step
) values starting from start
.
Example iterator = iter.count_from_by(1, 2)\n\nassert iterator.next() == 1\nassert iterator.next() == 3\nassert iterator.next() == 5\nassert iterator.next() == 7\nassert iterator.next() == 9\n
Parameters:
Name Type Description Default start
int
The value to start from.
required step
int
The value to step by.
required Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count_from_by(cls, start: int, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `start`.\n\n Example:\n ```python\n iterator = iter.count_from_by(1, 2)\n\n assert iterator.next() == 1\n assert iterator.next() == 3\n assert iterator.next() == 5\n assert iterator.next() == 7\n assert iterator.next() == 9\n ```\n\n Arguments:\n start: The value to start from.\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.create(count(start, step))\n
"},{"location":"reference/iters/#iters.iters.Iter.count_from","title":"count_from(start: int) -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by 1
) values starting from start
.
This is a shorthand for:
iter.count_from_by(start, 1)\n
Parameters:
Name Type Description Default start
int
The value to start from.
required Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count_from(cls, start: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `start`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(start, 1)\n ```\n\n Arguments:\n start: The value to start from.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(start, DEFAULT_STEP)\n
"},{"location":"reference/iters/#iters.iters.Iter.count_by","title":"count_by(step: int) -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by step
) values starting from 0
.
This is a shorthand for:
iter.count_from_by(0, step)\n
Parameters:
Name Type Description Default step
int
The value to step by.
required Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count_by(cls, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, step)\n ```\n\n Arguments:\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, step)\n
"},{"location":"reference/iters/#iters.iters.Iter.count","title":"count() -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by 1
) values starting from 0
.
This is a shorthand for:
iter.count_from_by(0, 1)\n
Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count(cls) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, 1)\n ```\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, DEFAULT_STEP)\n
"},{"location":"reference/iters/#iters.iters.Iter.iterate","title":"iterate(function: Unary[V, V], value: V) -> Iter[V]
classmethod
","text":"Creates an iterator that iterates function calls endlessly, i.e. value
, function(value)
, function(function(value))
, ...
Example zero = 0\n\ndef successor(natural: int) -> int:\n return natural + 1\n\nnaturals = iter.iterate(successor, zero)\n
Parameters:
Name Type Description Default function
Unary[V, V]
The function to iterate.
required value
V
The value to begin iteration with.
required Returns:
Type Description Iter[V]
An Iter[V]
over iteration results.
Source code in iters/iters.py
@classmethod\ndef iterate(cls, function: Unary[V, V], value: V) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls endlessly, i.e. `value`,\n `function(value)`, `function(function(value))`, ...\n\n Example:\n ```python\n zero = 0\n\n def successor(natural: int) -> int:\n return natural + 1\n\n naturals = iter.iterate(successor, zero)\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value))\n
"},{"location":"reference/iters/#iters.iters.Iter.iterate_exactly","title":"iterate_exactly(function: Unary[V, V], value: V, count: int) -> Iter[V]
classmethod
","text":"Creates an iterator that iterates function calls exactly count
times.
This is a shorthand for iter.iterate(function, value).take(count)
.
Example def wrap(item: T) -> List[T]:\n return [item]\n\niter.iterate_exactly(wrap, 13, 5).list() == [\n 13, [13], [[13]], [[[13]]], [[[[13]]]]\n]\n
Parameters:
Name Type Description Default function
Unary[V, V]
The function to iterate.
required value
V
The value to begin iteration with.
required count
int
The amount of function iterations.
required Returns:
Type Description Iter[V]
An Iter[V]
over iteration results.
Source code in iters/iters.py
@classmethod\ndef iterate_exactly(cls, function: Unary[V, V], value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls exactly `count` times.\n\n This is a shorthand for\n [`iter.iterate(function, value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n def wrap(item: T) -> List[T]:\n return [item]\n\n iter.iterate_exactly(wrap, 13, 5).list() == [\n 13, [13], [[13]], [[[13]]], [[[[13]]]]\n ]\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n count: The amount of function iterations.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value, count))\n
"},{"location":"reference/iters/#iters.iters.Iter.iter_except","title":"iter_except(function: Nullary[T], *errors: AnyErrorType) -> Iter[T]
classmethod
","text":"Creates an iterator that repeatedly calls function
until any of the errors
is encountered.
Example An interesting way to reverse arrays:
array = [1, 2, 3]\n\niter.iter_except(array.pop, IndexError).list() == [3, 2, 1]\n
Parameters:
Name Type Description Default function
Nullary[T]
The function to iterate.
required *errors
AnyErrorType
The errors to except
, stopping iteration.
()
Returns:
Type Description Iter[T]
An Iter[T]
over function results.
Source code in iters/iters.py
@classmethod\ndef iter_except(cls, function: Nullary[T], *errors: AnyErrorType) -> Iter[T]:\n \"\"\"Creates an iterator that repeatedly calls `function` until\n any of the `errors` is encountered.\n\n Example:\n An interesting way to reverse arrays:\n\n ```python\n array = [1, 2, 3]\n\n iter.iter_except(array.pop, IndexError).list() == [3, 2, 1]\n ```\n\n Arguments:\n function: The function to iterate.\n *errors: The errors to `except`, stopping iteration.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function results.\n \"\"\"\n return cls.create(iter_except(function, *errors))\n
"},{"location":"reference/iters/#iters.iters.Iter.iter_with","title":"iter_with(context_manager: ContextManager[Iterable[T]]) -> Iter[T]
classmethod
","text":"Creates an iterator over the iterable returned by context_manager
.
This is essentially equivalent to:
def iter_with(context_manager: ContextManager[Iterable[T]]) -> Iterator[T]:\n with context_manager as iterable:\n for item in iterable:\n yield item\n\niterator = iter(iter_with(context_manager))\n
This function can be used to open and close files, for example; let us consider parsing some file containing integers on every line.
Example array = iter.iter_with(open(\"file.in\")).map(int).list()\n
Parameters:
Name Type Description Default context_manager
ContextManager[Iterable[T]]
The context manager returning an iterable.
required Returns:
Type Description Iter[T]
An Iter[T]
over items in an iterable.
Source code in iters/iters.py
@classmethod\ndef iter_with(cls, context_manager: ContextManager[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator over the iterable returned by `context_manager`.\n\n This is essentially equivalent to:\n\n ```python\n def iter_with(context_manager: ContextManager[Iterable[T]]) -> Iterator[T]:\n with context_manager as iterable:\n for item in iterable:\n yield item\n\n iterator = iter(iter_with(context_manager))\n ```\n\n This function can be used to open and close files, for example;\n let us consider parsing some file containing integers on every line.\n\n Example:\n ```python\n array = iter.iter_with(open(\"file.in\")).map(int).list()\n ```\n\n Arguments:\n context_manager: The context manager returning an iterable.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over items in an iterable.\n \"\"\"\n return cls.create(iter_with(context_manager))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_chain","title":"create_chain(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator chaining iterables
together.
For example, it can be used to chain arrays.
Example a = [1, 2, 3]\nb = [4, 5, 6]\nc = [7, 8, 9]\n\nassert iter.create_chain(a, b, c).list() == a + b + c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to chain together.
()
Returns:
Type Description Iter[T]
An Iter[T]
over chained iterables.
Source code in iters/iters.py
@classmethod\ndef create_chain(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator chaining `iterables` together.\n\n For example, it can be used to chain arrays.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [7, 8, 9]\n\n assert iter.create_chain(a, b, c).list() == a + b + c\n ```\n\n Arguments:\n *iterables: Iterables to chain together.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_chain_with","title":"create_chain_with(iterable: Iterable[Iterable[T]]) -> Iter[T]
classmethod
","text":"Creates an iterator chaining iterables in the iterable
together.
This function essentially flattens the iterable
provided.
Example matrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9],\n]\n\nresult = 45\n\nassert iter.create_chain_with(matrix).sum() == result\n
Parameters:
Name Type Description Default iterable
Iterable[Iterable[T]]
The iterable of iterables to chain.
required Returns:
Type Description Iter[T]
An Iter[T]
over chained iterables.
Source code in iters/iters.py
@classmethod\ndef create_chain_with(cls, iterable: Iterable[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator chaining iterables in the `iterable` together.\n\n This function essentially flattens the `iterable` provided.\n\n Example:\n ```python\n matrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9],\n ]\n\n result = 45\n\n assert iter.create_chain_with(matrix).sum() == result\n ```\n\n Arguments:\n iterable: The iterable of iterables to chain.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain_from_iterable(iterable))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_combine","title":"create_combine(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator combining iterables
.
This method is a slightly different version of create_interleave_longest
.
Example a = [1, 2, 3]\nb = [4, 5, 6]\nc = [1, 4, 2, 5, 3, 6]\n\nassert iter.combine(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to combine.
()
Returns:
Type Description Iter[T]
An Iter[T]
over combined iterables.
Source code in iters/iters.py
@classmethod\ndef create_combine(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator combining `iterables`.\n\n This method is a slightly different version of\n [`create_interleave_longest`][iters.iters.Iter.create_interleave_longest].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.combine(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to combine.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over combined iterables.\n \"\"\"\n return cls.create(combine(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_interleave","title":"create_interleave(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator interleaving iterables
.
Note This method stops when the shortest iterable is exhausted.
Example a = [1, 2, 3]\nb = [4, 5, 6, 7, 8, 9]\nc = [1, 4, 2, 5, 3, 6]\n\nassert iter.create_interleave(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to interleave.
()
Returns:
Type Description Iter[T]
An Iter[T]
over interleft iterables.
Source code in iters/iters.py
@classmethod\ndef create_interleave(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.create_interleave(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_interleave_longest","title":"create_interleave_longest(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator interleaving iterables
.
This method is a slightly different version of create_combine
.
Example a = [1, 2, 3]\nb = [4, 5, 6, 7, 8, 9]\nc = [1, 4, 2, 5, 3, 6, 7, 8, 9]\n\nassert iter.create_interleave_longest(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to interleave.
()
Returns:
Type Description Iter[T]
An Iter[T]
over interleft iterables.
Source code in iters/iters.py
@classmethod\ndef create_interleave_longest(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n This method is a slightly different version of\n [`create_combine`][iters.iters.Iter.create_combine].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6, 7, 8, 9]\n\n assert iter.create_interleave_longest(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave_longest(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_zip","title":"create_zip(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]
classmethod
","text":"Zips iterables
into an iterator of tuples, where the i-th tuple contains the i-th item from each of the iterables.
Note This method stops when the shortest iterable is exhausted.
Example x = (1, 2, 3, 4, 5)\n\ny = \"nekit\"\n\niter.create_zip(x, y).list() == [(1, \"n\"), (2, \"e\"), (3, \"k\"), (4, \"i\"), (5, \"t\")]\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to zip.
()
Returns:
Type Description Iter[DynamicTuple[Any]]
An Iter[Tuple[...]]
over zipped tuples.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_zip(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4, 5)\n\n y = \"nekit\"\n\n iter.create_zip(x, y).list() == [(1, \"n\"), (2, \"e\"), (3, \"k\"), (4, \"i\"), (5, \"t\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_zip_equal","title":"create_zip_equal(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]
classmethod
","text":"Zips iterables
into an iterator of tuples, where the i-th tuple contains the i-th item from each of the iterables.
This is the strict version of create_zip
.
Example x = (1, 2, 3)\n\ny = \"dev\"\n\niter.create_zip_equal(x, y).list() == [(1, \"d\"), (2, \"e\"), (3, \"v\")]\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to zip.
()
Raises:
Type Description ValueError
Iterables have different lengths.
Returns:
Type Description Iter[DynamicTuple[Any]]
An Iter[Tuple[...]]
over zipped tuples.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_zip_equal(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is the strict version of [`create_zip`][iters.iters.Iter.create_zip].\n\n Example:\n ```python\n x = (1, 2, 3)\n\n y = \"dev\"\n\n iter.create_zip_equal(x, y).list() == [(1, \"d\"), (2, \"e\"), (3, \"v\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Raises:\n ValueError: Iterables have different lengths.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_equal(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_zip_longest","title":"create_zip_longest(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]
classmethod
","text":"Zips iterables
into an iterator of tuples, where the i-th tuple contains the i-th item from each of the iterables.
This is a version of create_zip
that places None
in place of a j-th item of an i-th tuple when a j-th iterable is exhausted.
Example x = (1, 2, 3, 4)\n\ny = \"dev\"\n\nf = \"x\"\n\ndef process(a: Option[int], b: Option[str]) -> Tuple[int, str]:\n return (a.unwrap_or(0), b.unwrap_or(f))\n\nassert (\n iter.create_zip_longest(x, y)\n .map(unpack_binary(process))\n .list()\n) == [(1, \"d\"), (2, \"e\"), (3, \"v\"), (4, \"x\")]\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to zip.
()
Returns:
Type Description Iter[DynamicTuple[Option[Any]]]
An Iter[Tuple[...]]
over zipped tuples.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_zip_longest(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is a version of [`create_zip`][iters.iters.Iter.create_zip] that places [`None`][None]\n in place of a *j*-th item of an *i*-th tuple when a *j*-th iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4)\n\n y = \"dev\"\n\n f = \"x\"\n\n def process(a: Option[int], b: Option[str]) -> Tuple[int, str]:\n return (a.unwrap_or(0), b.unwrap_or(f))\n\n assert (\n iter.create_zip_longest(x, y)\n .map(unpack_binary(process))\n .list()\n ) == [(1, \"d\"), (2, \"e\"), (3, \"v\"), (4, \"x\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_longest(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_cartesian_product","title":"create_cartesian_product(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]
classmethod
","text":"Creates an iterator over the Cartesian product of iterables
.
Warning It only makes sense to compute the product of finite iterables.
Example a = (1, 2, 3)\nb = \"xyz\"\n\nc = [\n (1, \"x\"), (1, \"y\"), (1, \"z\"),\n (2, \"x\"), (2, \"y\"), (2, \"z\"),\n (3, \"x\"), (3, \"y\"), (3, \"z\"),\n]\n\nassert iter.create_cartesian_product(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to compute the Cartesian product of.
()
Returns:
Type Description Iter[DynamicTuple[Any]]
An Iter[Tuple[...]]
over the Cartesian product of iterables.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_cartesian_product(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Creates an iterator over the\n [*Cartesian product*](https://en.wikipedia.org/wiki/Cartesian_product) of `iterables`.\n\n Warning:\n It only makes sense to compute the product of finite iterables.\n\n Example:\n ```python\n a = (1, 2, 3)\n b = \"xyz\"\n\n c = [\n (1, \"x\"), (1, \"y\"), (1, \"z\"),\n (2, \"x\"), (2, \"y\"), (2, \"z\"),\n (3, \"x\"), (3, \"y\"), (3, \"z\"),\n ]\n\n assert iter.create_cartesian_product(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to compute the Cartesian product of.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over the Cartesian product of iterables.\n \"\"\"\n return cls.create(cartesian_product(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.reversed","title":"reversed(reversible: Reversible[T]) -> Iter[T]
classmethod
","text":"Creates an iterator over the reversed reversible
.
Example assert iter.reversed([1, 2, 3]).list() == [3, 2, 1]\n
Parameters:
Name Type Description Default reversible
Reversible[T]
The reversible to reverse.
required Returns:
Type Description Iter[T]
An Iter[T]
over the reversed reversible.
Source code in iters/iters.py
@classmethod\ndef reversed(cls, reversible: Reversible[T]) -> Iter[T]:\n \"\"\"Creates an iterator over the reversed `reversible`.\n\n Example:\n ```python\n assert iter.reversed([1, 2, 3]).list() == [3, 2, 1]\n ```\n\n Arguments:\n reversible: The reversible to reverse.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over the reversed reversible.\n \"\"\"\n return cls.create(standard_reversed(reversible))\n
"},{"location":"reference/iters/#iters.iters.Iter.function","title":"function(function: Nullary[T], sentinel: V) -> Iter[T]
classmethod
","text":"Creates an iterator over function
call results until it returns the sentinel
.
Example EMPTY_BYTES = bytes()\n\nREAD_BINARY = \"rb\"\n\nCHUNK_SIZE = 65536\n\ndef read_chunk(file: BinaryIO) -> Nullary[bytes]:\n def reader(size: int = CHUNK_SIZE) -> bytes:\n return file.read(size)\n\n return reader\n\nwith path.open(READ_BINARY) as file:\n iter.function(read_chunk(file), EMPTY_BYTES).for_each(process_chunk)\n
Parameters:
Name Type Description Default function
Nullary[T]
The function to iterate.
required sentinel
V
The sentinel to stop at.
required Returns:
Type Description Iter[T]
An Iter[T]
over function calls until the sentinel
is met.
Source code in iters/iters.py
@classmethod\ndef function(cls, function: Nullary[T], sentinel: V) -> Iter[T]:\n \"\"\"Creates an iterator over `function` call results until it returns the `sentinel`.\n\n Example:\n ```python\n EMPTY_BYTES = bytes()\n\n READ_BINARY = \"rb\"\n\n CHUNK_SIZE = 65536\n\n def read_chunk(file: BinaryIO) -> Nullary[bytes]:\n def reader(size: int = CHUNK_SIZE) -> bytes:\n return file.read(size)\n\n return reader\n\n with path.open(READ_BINARY) as file:\n iter.function(read_chunk(file), EMPTY_BYTES).for_each(process_chunk)\n ```\n\n Arguments:\n function: The function to iterate.\n sentinel: The sentinel to stop at.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function calls until the `sentinel` is met.\n \"\"\"\n return cls.create(iter_function(function, sentinel))\n
"},{"location":"reference/iters/#iters.iters.Iter.unwrap","title":"unwrap() -> Iterator[T]
","text":"Unwraps the underlying iterator.
Returns:
Type Description Iterator[T]
The underlying iterator.
Source code in iters/iters.py
def unwrap(self) -> Iterator[T]:\n \"\"\"Unwraps the underlying iterator.\n\n Returns:\n The underlying iterator.\n \"\"\"\n return self.iterator\n
"},{"location":"reference/iters/#iters.iters.Iter.iter","title":"iter() -> Iter[T]
","text":"Simply returns self
.
Returns:
Type Description Iter[T]
self
, the current iterator.
Source code in iters/iters.py
def iter(self) -> Iter[T]:\n \"\"\"Simply returns `self`.\n\n Returns:\n `self`, the current iterator.\n \"\"\"\n return self\n
"},{"location":"reference/iters/#iters.iters.Iter.next","title":"next() -> Option[T]
","text":"Returns the next item in the iterator.
Example value = 42\n\niterator = iter.once(value)\n\nassert iterator.next().unwrap() is value\n
Returns:
Type Description Option[T]
The next item.
Source code in iters/iters.py
def next(self) -> Option[T]:\n \"\"\"Returns the next item in the iterator.\n\n Example:\n ```python\n value = 42\n\n iterator = iter.once(value)\n\n assert iterator.next().unwrap() is value\n ```\n\n Returns:\n The next item.\n \"\"\"\n return wrap_marked(next(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.compare","title":"compare(other: Iterable[ST]) -> Ordering
","text":"Compares self
with the other
iterable.
Example array = [1, 2, 3]\n\niterator = iter(array)\n\nassert iterator.compare(array).is_equal()\n
Parameters:
Name Type Description Default other
Iterable[ST]
The other iterable.
required Returns:
Type Description Ordering
The Ordering
representing the result.
Source code in iters/iters.py
def compare(self: Iter[ST], other: Iterable[ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable.\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.compare(array).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other)\n
"},{"location":"reference/iters/#iters.iters.Iter.compare_by","title":"compare_by(other: Iterable[T], key: Unary[T, ST]) -> Ordering
","text":"Compares self
with the other
iterable using the key
function.
Example array = [13, 34, 42]\nnegative = [-x for x in array]\n\niterator = iter(array)\n\nassert iterator.compare_by(negative, abs).is_equal()\n
Parameters:
Name Type Description Default other
Iterable[T]
The other iterable.
required key
Unary[T, ST]
The key function.
required Returns:
Type Description Ordering
The Ordering
representing the result.
Source code in iters/iters.py
def compare_by(self, other: Iterable[T], key: Unary[T, ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable using the `key` function.\n\n Example:\n ```python\n array = [13, 34, 42]\n negative = [-x for x in array]\n\n iterator = iter(array)\n\n assert iterator.compare_by(negative, abs).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n key: The key function.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other, key)\n
"},{"location":"reference/iters/#iters.iters.Iter.length","title":"length() -> int
","text":"Computes the length of the iterator.
Example assert iter.repeat_exactly(7, 7).length() == 7\n
Warning This function exhausts the underlying iterator!
Returns:
Type Description int
The length of the iterator.
Source code in iters/iters.py
def length(self) -> int:\n \"\"\"Computes the length of the iterator.\n\n Example:\n ```python\n assert iter.repeat_exactly(7, 7).length() == 7\n ```\n\n Warning:\n This function exhausts the underlying iterator!\n\n Returns:\n The length of the iterator.\n \"\"\"\n return iter_length(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.first","title":"first() -> Option[T]
","text":"Returns the first item in the iterator.
Example value = 69\n\niterator = iter.once(value)\n\nassert iterator.first().unwrap() is value\n
Returns:
Type Description Option[T]
The first item.
Source code in iters/iters.py
def first(self) -> Option[T]:\n \"\"\"Returns the first item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.first().unwrap() is value\n ```\n\n Returns:\n The first item.\n \"\"\"\n return wrap_marked(first(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.last","title":"last() -> Option[T]
","text":"Returns the last item in the iterator.
Example value = 69\n\niterator = iter.once(value)\n\nassert iterator.last().unwrap() is value\n
Returns:
Type Description Option[T]
The last item.
Source code in iters/iters.py
def last(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.last_with_tail","title":"last_with_tail() -> Option[T]
","text":"Returns the last item in the iterator.
Note This method uses the tail
function.
Example value = 69\n\niterator = iter.once(value)\n\nassert iterator.last_with_tail().unwrap() is value\n
Returns:
Type Description Option[T]
The last item.
Source code in iters/iters.py
def last_with_tail(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Note:\n This method uses the [`tail`][iters.utils.tail] function.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last_with_tail().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last_with_tail(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.collect","title":"collect(function: Unary[Iterable[T], U]) -> U
","text":"Collects the iterator with the function
.
This is equivalent to:
function(iterator.unwrap())\n
Example array = [1, 2, 3]\n\niterator = iter(array)\n\nassert iterator.collect(list) == array\n
Parameters:
Name Type Description Default function
Unary[Iterable[T], U]
The function to use.
required Returns:
Type Description U
The result of the function
call.
Source code in iters/iters.py
def collect(self, function: Unary[Iterable[T], U]) -> U:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n function(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.collect(list) == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call.\n \"\"\"\n return function(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.collect_iter","title":"collect_iter(function: Unary[Iterable[T], Iterable[U]]) -> Iter[U]
","text":"Collects the iterator with the function
.
This is equivalent to:
iterator.create(iterator.collect(function))\n
Example from typing import TypeVar\n\nT = TypeVar(\"T\")\n\ndef identity(item: T) -> T:\n return item\n\narray = [13, 25, 34]\n\niterator = iter(array).collect_iter(identity)\n\nassert iterator.list() == array\n
Parameters:
Name Type Description Default function
Unary[Iterable[T], Iterable[U]]
The function to use.
required Returns:
Type Description Iter[U]
The result of the function
call, wrapped back into an iterator.
Source code in iters/iters.py
def collect_iter(self, function: Unary[Iterable[T], Iterable[U]]) -> Iter[U]:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n iterator.create(iterator.collect(function))\n ```\n\n Example:\n ```python\n from typing import TypeVar\n\n T = TypeVar(\"T\")\n\n def identity(item: T) -> T:\n return item\n\n array = [13, 25, 34]\n\n iterator = iter(array).collect_iter(identity)\n\n assert iterator.list() == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call, wrapped back into an iterator.\n \"\"\"\n return self.create(self.collect(function))\n
"},{"location":"reference/iters/#iters.iters.Iter.list","title":"list() -> List[T]
","text":"Collects the iterator into the List[T]
.
This is equivalent to:
list(iterator.unwrap())\n
Example array = [1, 2, 3]\n\niterator = iter(array)\n\nassert iterator.list() == array\n
Returns:
Type Description List[T]
The List[T]
over the iterator.
Source code in iters/iters.py
def list(self) -> List[T]:\n \"\"\"Collects the iterator into the [`List[T]`][list].\n\n This is equivalent to:\n\n ```python\n list(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.list() == array\n ```\n\n Returns:\n The [`List[T]`][list] over the iterator.\n \"\"\"\n return list(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.set","title":"set() -> Set[Q]
","text":"Collects the iterator into the Set[Q]
.
Warning The items of the iterator have to be hashable for this method to work.
This is equivalent to:
set(iterator.unwrap())\n
Example set = {13, 42, 69}\n\niterator = iter(set)\n\nassert iterator.set() == set\n
Returns:
Type Description Set[Q]
The Set[Q]
over the iterator.
Source code in iters/iters.py
def set(self: Iter[Q]) -> Set[Q]:\n \"\"\"Collects the iterator into the [`Set[Q]`][set].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n set(iterator.unwrap())\n ```\n\n Example:\n ```python\n set = {13, 42, 69}\n\n iterator = iter(set)\n\n assert iterator.set() == set\n ```\n\n Returns:\n The [`Set[Q]`][set] over the iterator.\n \"\"\"\n return set(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.ordered_set","title":"ordered_set() -> OrderedSet[Q]
","text":"Collects the iterator into the OrderedSet[Q]
.
Warning The items of the iterator have to be hashable for this method to work.
This is equivalent to:
ordered_set(iterator.unwrap())\n
Example ordered_set = OrderedSet([13, 42, 69])\n\niterator = iter(ordered_set)\n\nassert iterator.ordered_set() == ordered_set\n
Returns:
Type Description OrderedSet[Q]
The OrderedSet[Q]
over the iterator.
Source code in iters/iters.py
def ordered_set(self: Iter[Q]) -> OrderedSet[Q]:\n \"\"\"Collects the iterator into the [`OrderedSet[Q]`][iters.ordered_set.OrderedSet].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n ordered_set(iterator.unwrap())\n ```\n\n Example:\n ```python\n ordered_set = OrderedSet([13, 42, 69])\n\n iterator = iter(ordered_set)\n\n assert iterator.ordered_set() == ordered_set\n ```\n\n Returns:\n The [`OrderedSet[Q]`][iters.ordered_set.OrderedSet] over the iterator.\n \"\"\"\n return ordered_set(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.tuple","title":"tuple() -> DynamicTuple[T]
","text":"Collects the iterator into the Tuple[T, ...]
.
This is equivalent to:
tuple(iterator.unwrap())\n
Example tuple = (-1, 0, 1)\n\niterator = iter(tuple)\n\nassert iterator.tuple() == tuple\n
Returns:
Type Description DynamicTuple[T]
The Tuple[T, ...]
over the iterator.
Source code in iters/iters.py
def tuple(self) -> DynamicTuple[T]:\n \"\"\"Collects the iterator into the [`Tuple[T, ...]`][tuple].\n\n This is equivalent to:\n\n ```python\n tuple(iterator.unwrap())\n ```\n\n Example:\n ```python\n tuple = (-1, 0, 1)\n\n iterator = iter(tuple)\n\n assert iterator.tuple() == tuple\n ```\n\n Returns:\n The [`Tuple[T, ...]`][tuple] over the iterator.\n \"\"\"\n return tuple(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.dict","title":"dict() -> Dict[Q, V]
","text":"Collects the iterator into the Dict[Q, V]
.
Warning The first item in each couple has to be hashable for this method to work.
This is equivalent to:
dict(iterator.unwrap())\n
Example mapping = {13: \"nekit\", 42: \"dev\"}\n\niterator = iter(mapping.items())\n\nassert iterator.dict() == mapping\n
Returns:
Type Description Dict[Q, V]
The Dict[Q, V]
over the iterator.
Source code in iters/iters.py
def dict(self: Iter[Tuple[Q, V]]) -> Dict[Q, V]:\n \"\"\"Collects the iterator into the [`Dict[Q, V]`][dict].\n\n Warning:\n The first item in each couple has to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n dict(iterator.unwrap())\n ```\n\n Example:\n ```python\n mapping = {13: \"nekit\", 42: \"dev\"}\n\n iterator = iter(mapping.items())\n\n assert iterator.dict() == mapping\n ```\n\n Returns:\n The [`Dict[Q, V]`][dict] over the iterator.\n \"\"\"\n return dict(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.join","title":"join(string: AnyStr) -> AnyStr
","text":"Joins the iterator using the string
.
Warning The iterator must contain only string items for this method to work.
This is equivalent to:
string.join(iterator.unwrap())\n
Example result = \"melody, nekit\"\n\nstring = \", \"\n\niterator = iter(result.split(string))\n\nassert iterator.join(string) == result\n
Returns:
Type Description AnyStr
The joined str
or bytes
depending on the string
type.
Source code in iters/iters.py
def join(self: Iter[AnyStr], string: AnyStr) -> AnyStr:\n \"\"\"Joins the iterator using the `string`.\n\n Warning:\n The iterator must contain only string items for this method to work.\n\n This is equivalent to:\n\n ```python\n string.join(iterator.unwrap())\n ```\n\n Example:\n ```python\n result = \"melody, nekit\"\n\n string = \", \"\n\n iterator = iter(result.split(string))\n\n assert iterator.join(string) == result\n ```\n\n Returns:\n The joined [`str`][str] or [`bytes`][bytes] depending on the `string` type.\n \"\"\"\n return string.join(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.string","title":"string() -> str
","text":"Joins the iterator into the str
string.
Warning The iterator must contain only items of type str
for this method to work.
This is equivalent to:
iterator.join(EMPTY_STRING)\n
Example strings = (\"x\", \"y\", \"z\")\nstring = \"xyz\"\n\niterator = iter(strings)\n\nassert iterator.string() == string\n
Returns:
Type Description str
The joined str
string.
Source code in iters/iters.py
def string(self: Iter[str]) -> str:\n \"\"\"Joins the iterator into the [`str`][str] string.\n\n Warning:\n The iterator must contain only items of type [`str`][str] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_STRING)\n ```\n\n Example:\n ```python\n strings = (\"x\", \"y\", \"z\")\n string = \"xyz\"\n\n iterator = iter(strings)\n\n assert iterator.string() == string\n ```\n\n Returns:\n The joined [`str`][str] string.\n \"\"\"\n return self.join(EMPTY_STRING)\n
"},{"location":"reference/iters/#iters.iters.Iter.bytes","title":"bytes() -> bytes
","text":"Joins the iterator into the bytes
string.
Warning The iterator must contain only items of type bytes
for this method to work.
This is equivalent to:
iterator.join(EMPTY_BYTES)\n
Returns:
Type Description bytes
The joined bytes
string.
Source code in iters/iters.py
def bytes(self: Iter[bytes]) -> bytes:\n \"\"\"Joins the iterator into the [`bytes`][bytes] string.\n\n Warning:\n The iterator must contain only items of type [`bytes`][bytes] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_BYTES)\n ```\n\n Returns:\n The joined [`bytes`][bytes] string.\n \"\"\"\n return self.join(EMPTY_BYTES)\n
"},{"location":"reference/iters/#iters.iters.Iter.count_dict","title":"count_dict() -> Counter[Q]
","text":"Collects the iterator into the Counter[Q]
.
Warning The items of the iterator have to be hashable for this method to work.
Example bits = (0, 1, 1, 0, 1, 1, 1, 0)\n\nresult = [(1, 5), (0, 3)]\n\niterator = iter(bits)\n\nassert iterator.count_dict().most_common() == result\n
Returns:
Type Description Counter[Q]
The Counter[Q]
over the items of the iterator.
Source code in iters/iters.py
def count_dict(self: Iter[Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n Example:\n ```python\n bits = (0, 1, 1, 0, 1, 1, 1, 0)\n\n result = [(1, 5), (0, 3)]\n\n iterator = iter(bits)\n\n assert iterator.count_dict().most_common() == result\n ```\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the items of the iterator.\n \"\"\"\n return count_dict(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.count_dict_by","title":"count_dict_by(key: Unary[T, Q]) -> Counter[Q]
","text":"Collects the iterator into the Counter[Q]
by applying the key
function.
Example sets = [{}, {0}, {1}, {0, 1}]\n\niterator = iter(sets)\n\nresult = [(1, 2), (2, 1), (0, 1)]\n\nassert iterator.count_dict_by(len).most_common() == result\n
Parameters:
Name Type Description Default key
Unary[T, Q]
The key function.
required Returns:
Type Description Counter[Q]
The Counter[Q]
over the keys corresponding to the items of the iterator.
Source code in iters/iters.py
def count_dict_by(self, key: Unary[T, Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter]\n by applying the `key` function.\n\n Example:\n ```python\n sets = [{}, {0}, {1}, {0, 1}]\n\n iterator = iter(sets)\n\n result = [(1, 2), (2, 1), (0, 1)]\n\n assert iterator.count_dict_by(len).most_common() == result\n ```\n\n Arguments:\n key: The key function.\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the keys\n corresponding to the items of the iterator.\n \"\"\"\n return count_dict(self.iterator, key)\n
"},{"location":"reference/iters/#iters.iters.Iter.cartesian_power","title":"cartesian_power(power: int) -> Iter[DynamicTuple[T]]
","text":"Creates an iterator over the Cartesian power of the iterator.
Warning It only makes sense to compute the Cartesian power of finite iterators.
Example bits = (0, 1)\nresult = ((0, 0), (0, 1), (1, 0), (1, 1))\n\niterator = iter(bits)\n\nassert iterator.cartesian_power(2).tuple() == result\n
Parameters:
Name Type Description Default power
int
The power to \"raise\" the iterator to.
required Returns:
Type Description Iter[DynamicTuple[T]]
An [Iter[Tuple[...]]
] over the Cartesian power of the iterator.
Source code in iters/iters.py
def cartesian_power(self, power: int) -> Iter[DynamicTuple[T]]:\n \"\"\"Creates an iterator over the\n [*Cartesian power*](https://en.wikipedia.org/wiki/Cartesian_product) of the iterator.\n\n Warning:\n It only makes sense to compute the Cartesian power of finite iterators.\n\n Example:\n ```python\n bits = (0, 1)\n result = ((0, 0), (0, 1), (1, 0), (1, 1))\n\n iterator = iter(bits)\n\n assert iterator.cartesian_power(2).tuple() == result\n ```\n\n Arguments:\n power: The power to \"raise\" the iterator to.\n\n Returns:\n An [`Iter[Tuple[...]]`] over the Cartesian power of the iterator.\n \"\"\"\n return self.create(cartesian_power(power, self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.power_set","title":"power_set() -> Iter[DynamicTuple[T]]
","text":"Computes the power set of the iterator.
The power set of $S$ contains all subsets of $S$, including the empty set $\\varnothing$ and $S$ itself. The power set is often denoted as $2^S$ since if $|S| = n$, then $|2^S| = 2^n$.
Returns:
Type Description Iter[DynamicTuple[T]]
An iterator over the power set of the iterator.
Source code in iters/iters.py
def power_set(self) -> Iter[DynamicTuple[T]]:\n \"\"\"Computes the power set of the iterator.\n\n The power set of $S$ contains all subsets of $S$, including\n the empty set $\\\\varnothing$ and $S$ itself.\n The power set is often denoted as $2^S$ since if $|S| = n$, then $|2^S| = 2^n$.\n\n Returns:\n An iterator over the power set of the iterator.\n \"\"\"\n return self.create(power_set(self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.unique","title":"unique() -> Iter[T]
","text":"Creates an iterator over the unique items in the iterator.
This function may be slower than unique_fast
in case T
is not Hashable
.
To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.
Example >>> iterator = iter.of(0, 1, 1, 0, 1, 1, 1, 0)\n>>> iterator.unique().tuple()\n(0, 1)\n
Returns:
Type Description Iter[T]
An iterator over the unique items in the iterator.
Source code in iters/iters.py
def unique(self) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator.\n\n This function may be slower than [`unique_fast`][iters.iters.Iter.unique_fast]\n in case `T` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, 1, 0, 1, 1, 1, 0)\n >>> iterator.unique().tuple()\n (0, 1)\n ```\n\n Returns:\n An iterator over the unique items in the iterator.\n \"\"\"\n return self.create(unique(self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.unique_by","title":"unique_by(key: Unary[T, V]) -> Iter[T]
","text":"Creates an iterator over the unique items in the iterator based on the given key
.
This function may be slower than unique_fast_by
in case V
is not Hashable
.
To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.
Example >>> iterator = iter.of(0, 1, -1)\n>>> iterator.unique_by(abs).tuple()\n(0, 1)\n
Parameters:
Name Type Description Default key
Unary[T, V]
The key to use in determining uniqueness.
required Returns:
Type Description Iter[T]
An iterator over the unique items in the iterator based on the given key
.
Source code in iters/iters.py
def unique_by(self, key: Unary[T, V]) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator based on the given `key`.\n\n This function may be slower than [`unique_fast_by`][iters.iters.Iter.unique_fast_by]\n in case `V` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, -1)\n >>> iterator.unique_by(abs).tuple()\n (0, 1)\n ```\n\n Arguments:\n key: The key to use in determining uniqueness.\n\n Returns:\n An iterator over the unique items in the iterator based on the given `key`.\n \"\"\"\n return self.create(unique(self.iterator, key))\n
"},{"location":"reference/iters/#iters.iters.Iter.partition","title":"partition(predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]
","text":"Partitions the iterator into two iterators safely based on the given predicate
, loading all items into memory!
See predicates for more information on the predicate
argument.
Example Suppose we have the following function:
def is_positive(z: int) -> bool:\n return z > 0\n
Then
>>> iterator = iter.of(-1, 0, 1)\n>>> positive, non_positive = iterator.partition(is_positive)\n>>> positive.list()\n[1]\n>>> non_positive.list()\n[-1, 0]\n
Note This method exhausts the underlying iterator.
Parameters:
Name Type Description Default predicate
Optional[Predicate[T]]
The predicate to use in partitioning the iterator.
required Returns:
Type Description Pair[Iter[T]]
A tuple of two iterators, the former containing the items that match the predicate,
Pair[Iter[T]]
and the latter containing items that do not match the predicate.
Source code in iters/iters.py
def partition(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *safely* based on the given `predicate`,\n loading **all** items into memory!\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_positive(z: int) -> bool:\n return z > 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> positive, non_positive = iterator.partition(is_positive)\n >>> positive.list()\n [1]\n >>> non_positive.list()\n [-1, 0]\n ```\n\n Note:\n This method exhausts the underlying iterator.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n
"},{"location":"reference/iters/#iters.iters.Iter.partition_unsafe","title":"partition_unsafe(predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]
","text":"Partitions the iterator into two iterators unsafely based on the given predicate
.
See predicates for more information on the predicate
argument.
Example Suppose we have the following function:
def is_negative(z: int) -> bool:\n return z < 0\n
Then
>>> iterator = iter.of(-1, 0, 1)\n>>> negative, non_negative = iterator.partition_unsafe(is_negative)\n>>> non_negative.list()\n[0, 1]\n>>> negative.list()\n[-1]\n
Warning This method is not thread-safe!
Note This method works on the underlying iterator, so using the original iterator is not recommended after calling this method.
Parameters:
Name Type Description Default predicate
Optional[Predicate[T]]
The predicate to use in partitioning the iterator.
required Returns:
Type Description Pair[Iter[T]]
A tuple of two iterators, the former containing the items that match the predicate,
Pair[Iter[T]]
and the latter containing items that do not match the predicate.
Source code in iters/iters.py
def partition_unsafe(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *unsafely* based on the given `predicate`.\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_negative(z: int) -> bool:\n return z < 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> negative, non_negative = iterator.partition_unsafe(is_negative)\n >>> non_negative.list()\n [0, 1]\n >>> negative.list()\n [-1]\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method works on the underlying iterator, so using the original iterator\n is not recommended after calling this method.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition_unsafe(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n
"},{"location":"reference/iters/#iters.iters.Iter.copy","title":"copy() -> Iter[T]
","text":"Copies the iterator safely, loading all items into memory!
Example >>> iterator = iter.of(1, 2, 3)\n>>> copy = iterator.copy()\n>>> iterator.tuple()\n(1, 2, 3)\n>>> copy.tuple()\n(1, 2, 3)\n
Note This method replaces the underlying iterator.
Returns:
Type Description Iter[T]
A copy of the iterator.
Source code in iters/iters.py
def copy(self) -> Iter[T]:\n \"\"\"Copies the iterator *safely*, loading **all** items into memory!\n\n Example:\n ```python\n >>> iterator = iter.of(1, 2, 3)\n >>> copy = iterator.copy()\n >>> iterator.tuple()\n (1, 2, 3)\n >>> copy.tuple()\n (1, 2, 3)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n
"},{"location":"reference/iters/#iters.iters.Iter.copy_unsafe","title":"copy_unsafe() -> Iter[T]
","text":"Copies the iterator unsafely.
Example >>> iterator = iter.of(13, 42, 69)\n>>> copy = iterator.copy_unsafe()\n>>> iterator.zip(copy).tuple()\n((13, 13), (42, 42), (69, 69))\n
Warning This method is not thread-safe!
Note This method replaces the underlying iterator.
Returns:
Type Description Iter[T]
A copy of the iterator.
Source code in iters/iters.py
def copy_unsafe(self) -> Iter[T]:\n \"\"\"Copies the iterator *unsafely*.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> copy = iterator.copy_unsafe()\n >>> iterator.zip(copy).tuple()\n ((13, 13), (42, 42), (69, 69))\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy_unsafe(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n
"},{"location":"reference/iters/#iters.iters.Iter.spy","title":"spy(size: int) -> List[T]
","text":"Spies on at most size
next items of the iterator, without consuming them.
Example >>> iterator = iter.of(13, 34, 42)\n>>> iterator.spy(2)\n[13, 34]\n>>> iterator.spy(4)\n[13, 34, 42]\n>>> iterator.next()\nSome(13)\n
Note This method replaces the underlying iterator.
Parameters:
Name Type Description Default size
int
The amount of items to spy on.
required Returns:
Type Description List[T]
Up to size
next items of the iterator.
Source code in iters/iters.py
def spy(self, size: int) -> List[T]:\n \"\"\"Spies on at most `size` next items of the iterator, without consuming them.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.spy(2)\n [13, 34]\n >>> iterator.spy(4)\n [13, 34, 42]\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Arguments:\n size: The amount of items to spy on.\n\n Returns:\n Up to `size` next items of the iterator.\n \"\"\"\n result, iterator = spy(size, self.iterator)\n\n self._replace(iterator)\n\n return result\n
"},{"location":"reference/iters/#iters.iters.Iter.peek","title":"peek() -> Option[T]
","text":"Peeks at the next item in the iterator, without consuming it.
Example >>> iterator = iter.of(13, 34, 42)\n>>> iterator.peek()\nSome(13)\n>>> iterator.next()\nSome(13)\n
Note This method replaces the underlying iterator.
Returns:
Type Description Option[T]
The next item in the iterator, if one exists.
Source code in iters/iters.py
def peek(self) -> Option[T]:\n \"\"\"Peeks at the next item in the iterator, without consuming it.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.peek()\n Some(13)\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n The next item in the iterator, if one exists.\n \"\"\"\n item, iterator = peek(self.iterator, marker)\n\n self._replace(iterator)\n\n return wrap_marked(item)\n
"},{"location":"reference/iters/#iters.iters.Iter.has_next","title":"has_next() -> bool
","text":"Checks if the iterator has a next item (i.e. is non-empty).
Example >>> assert iter.once(1).has_next()\n>>> assert not iter.empty().has_next()\n
Note This method replaces the underlying iterator.
Returns:
Type Description bool
Whether the iterator has a next item.
Source code in iters/iters.py
def has_next(self) -> bool:\n \"\"\"Checks if the iterator has a next item (i.e. is non-empty).\n\n Example:\n ```python\n >>> assert iter.once(1).has_next()\n >>> assert not iter.empty().has_next()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator has a next item.\n \"\"\"\n result, iterator = has_next(self.iterator)\n\n self._replace(iterator)\n\n return result\n
"},{"location":"reference/iters/#iters.iters.Iter.is_empty","title":"is_empty() -> bool
","text":"Checks if the iterator is empty.
Example >>> assert iter.empty().is_empty()\n>>> assert not iter.once(0).is_empty()\n
Note This method replaces the underlying iterator.
Returns:
Type Description bool
Whether the iterator is empty.
Source code in iters/iters.py
def is_empty(self) -> bool:\n \"\"\"Checks if the iterator is empty.\n\n Example:\n ```python\n >>> assert iter.empty().is_empty()\n >>> assert not iter.once(0).is_empty()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator is empty.\n \"\"\"\n result, iterator = is_empty(self.iterator)\n\n self._replace(iterator)\n\n return result\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_last","title":"repeat_last() -> Iter[T]
","text":"Repeats the last item of the iterator indefinitely.
Example >>> iterator = iter.of(0, 1)\n>>> iterator.next()\nSome(0)\n>>> iterator.next()\nSome(1)\n>>> iterator.next()\nSome(1) # now repeating the last item\n
Returns:
Type Description Iter[T]
The iterator with the last item repeated indefinitely.
Source code in iters/iters.py
def repeat_last(self) -> Iter[T]:\n \"\"\"Repeats the last item of the iterator indefinitely.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1)\n >>> iterator.next()\n Some(0)\n >>> iterator.next()\n Some(1)\n >>> iterator.next()\n Some(1) # now repeating the last item\n ```\n\n Returns:\n The iterator with the last item repeated indefinitely.\n \"\"\"\n return self.create(repeat_last(self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_each","title":"repeat_each(count: int) -> Iter[T]
","text":"Repeat each item of the iterator count
times.
Example >>> iter.of(0, 1).repeat_each(2).tuple()\n(0, 0, 1, 1)\n
>>> iter.once(0).repeat_each(0).tuple()\n()\n
Parameters:
Name Type Description Default count
int
The amount of times to repeat each item.
required Returns:
Type Description Iter[T]
The iterator with each item repeated count
times.
Source code in iters/iters.py
def repeat_each(self, count: int) -> Iter[T]:\n \"\"\"Repeat each item of the iterator `count` times.\n\n Example:\n ```python\n >>> iter.of(0, 1).repeat_each(2).tuple()\n (0, 0, 1, 1)\n ```\n\n ```python\n >>> iter.once(0).repeat_each(0).tuple()\n ()\n ```\n\n Arguments:\n count: The amount of times to repeat each item.\n\n Returns:\n The iterator with each item repeated `count` times.\n \"\"\"\n return self.create(repeat_each(count, self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.inspect","title":"inspect(function: Inspect[T]) -> Iter[T]
","text":"Inspects each item of the iterator with the given function
.
Example >>> iter.of(1, 2, 3).inspect(print).consume()\n1\n2\n3\n
Parameters:
Name Type Description Default function
Inspect[T]
The inspecting function.
required Returns:
Type Description Iter[T]
The original iterator.
Source code in iters/iters.py
def inspect(self, function: Inspect[T]) -> Iter[T]:\n \"\"\"Inspects each item of the iterator with the given `function`.\n\n Example:\n ```python\n >>> iter.of(1, 2, 3).inspect(print).consume()\n 1\n 2\n 3\n ```\n\n Arguments:\n function: The inspecting function.\n\n Returns:\n The original iterator.\n \"\"\"\n return self.create(inspect(function, self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.into_async_iter","title":"into_async_iter() -> AsyncIter[T]
","text":"Converts an Iter[T]
into an AsyncIter[T]
.
Example >>> async_iterator = iter.of(13, 34, 42).into_async_iter()\n>>> await async_iterator.tuple()\n(13, 34, 42)\n
Returns:
Type Description AsyncIter[T]
The async iterator created from the iterator.
Source code in iters/iters.py
def into_async_iter(self) -> AsyncIter[T]:\n \"\"\"Converts an [`Iter[T]`][iters.iters.Iter] into\n an [`AsyncIter[T]`][iters.async_iters.AsyncIter].\n\n Example:\n ```python\n >>> async_iterator = iter.of(13, 34, 42).into_async_iter()\n >>> await async_iterator.tuple()\n (13, 34, 42)\n ```\n\n Returns:\n The async iterator created from the iterator.\n \"\"\"\n return async_iter(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.wrap_iter","title":"wrap_iter(function: Callable[PS, Iterable[T]]) -> Callable[PS, Iter[T]]
","text":"Wraps the function
returning Iterable[T]
to return Iter[T]
.
Parameters:
Name Type Description Default function
Callable[PS, Iterable[T]]
The function to wrap.
required Returns:
Type Description Callable[PS, Iter[T]]
The wrapping function.
Source code in iters/iters.py
def wrap_iter(function: Callable[PS, Iterable[T]]) -> Callable[PS, Iter[T]]:\n \"\"\"Wraps the `function` returning [`Iterable[T]`][typing.Iterable]\n to return [`Iter[T]`][iters.iters.Iter].\n\n Arguments:\n function: The function to wrap.\n\n Returns:\n The wrapping function.\n \"\"\"\n\n @wraps(function)\n def wrap(*args: PS.args, **kwargs: PS.kwargs) -> Iter[T]:\n return iter(function(*args, **kwargs))\n\n return wrap\n
"},{"location":"reference/mappings/","title":"Mappings","text":""},{"location":"reference/mappings/#iters.mappings.merge","title":"merge(*mappings: Mapping[Any, Any], **keywords: Any) -> Dict[Any, Any]
","text":"Merges multiple mappings
and keywords
into one dictionary.
Parameters:
Name Type Description Default *mappings
Mapping[Any, Any]
Mappings to merge.
()
**keywords
Any
Keywords to add to the merged dictionary.
{}
Returns:
Type Description Dict[Any, Any]
The merged dictionary.
Source code in iters/mappings.py
def merge(*mappings: Mapping[Any, Any], **keywords: Any) -> Dict[Any, Any]:\n \"\"\"Merges multiple `mappings` and `keywords` into one dictionary.\n\n Arguments:\n *mappings: Mappings to merge.\n **keywords: Keywords to add to the merged dictionary.\n\n Returns:\n The merged dictionary.\n \"\"\"\n merged: Dict[Any, Any] = {}\n\n for mapping in mappings:\n merged.update(mapping)\n\n merged.update(keywords)\n\n return merged\n
"},{"location":"reference/ordered_set/","title":"Ordered Set","text":""},{"location":"reference/ordered_set/#iters.ordered_set.LAST","title":"LAST = ~0
module-attribute
","text":"The last index.
"},{"location":"reference/ordered_set/#iters.ordered_set.ordered_set","title":"ordered_set = OrderedSet
module-attribute
","text":"An alias of OrderedSet
.
"},{"location":"reference/ordered_set/#iters.ordered_set.ordered_set_unchecked","title":"ordered_set_unchecked = ordered_set.create_unchecked
module-attribute
","text":"An alias of ordered_set.create_unchecked
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet","title":"OrderedSet
","text":" Bases: MutableSet[Q]
, Sequence[Q]
Represents ordered sets, i.e. mutable hash sets that preserve insertion order.
The implementation is rather simple: it uses an array to store the items and a hash map to store the indices of the items in the array along with ensuring uniqueness.
The complexity of the operations assumes that hash maps have O(1)
insertion, lookup, deletion, and clearing as well as that arrays have O(1)
by-index lookup, length-checking and clearing.
Source code in iters/ordered_set.py
class OrderedSet(MutableSet[Q], Sequence[Q]):\n \"\"\"Represents ordered sets, i.e. mutable hash sets that preserve insertion order.\n\n The implementation is rather simple: it uses an *array* to store the items\n and a *hash map* to store the indices of the items in the array along with ensuring uniqueness.\n\n The complexity of the operations assumes that *hash maps*\n have `O(1)` *insertion*, *lookup*, *deletion*, and *clearing* as well\n as that *arrays* have `O(1)` *by-index lookup*, *length-checking* and *clearing*.\n \"\"\"\n\n def __init__(self, iterable: Iterable[Q] = ()) -> None:\n self._items: List[Q] = []\n self._item_to_index: Dict[Q, int] = {}\n\n self.update(iterable)\n\n @classmethod\n def create(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [0, 1, 1, 0, 1, 1, 1, 0]\n >>> order_set = ordered_set.create(array)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n return cls(iterable) # type: ignore\n\n @classmethod\n def create_unchecked(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable without checking if the items are unique.\n\n This method is useful when constructing an ordered set from an iterable that is known to\n contain unique items only.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [1, 2, 3] # we know that the items are unique\n >>> order_set = ordered_set.create_unchecked(array)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n self: OrderedSet[R] = cls.create()\n\n items = self._items\n item_to_index = self._item_to_index\n\n items.extend(iterable)\n\n for index, item in enumerate(items):\n item_to_index[item] = index\n\n return self\n\n @classmethod\n def create_union(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the union of given iterables.\n\n Arguments:\n *iterables: The iterables to create the ordered set union from.\n\n Returns:\n The ordered set union.\n \"\"\"\n return cls.create(chain(*iterables))\n\n @classmethod\n def create_intersection(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the intersection of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set intersection from.\n\n Returns:\n The ordered set intersection.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_intersection(*tail)\n\n return cls.create()\n\n @classmethod\n def create_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the orderd set difference from.\n\n Returns:\n The ordered set difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_difference(*tail)\n\n return cls.create()\n\n @classmethod\n def create_symmetric_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the symmetric difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set symmetric difference from.\n\n Returns:\n The ordered set symmetric difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_symmetric_difference(*tail)\n\n return cls.create()\n\n def __len__(self) -> int:\n return len(self._items)\n\n @overload\n def __getitem__(self, index: int) -> Q:\n ...\n\n @overload\n def __getitem__(self, index: slice) -> OrderedSet[Q]:\n ...\n\n def __getitem__(self, index: Union[int, slice]) -> Union[Q, OrderedSet[Q]]:\n if is_slice(index):\n if index == SLICE_ALL:\n return self.copy()\n\n return self.create_unchecked(self._items[index])\n\n return self._items[index] # type: ignore\n\n def copy(self) -> OrderedSet[Q]:\n \"\"\"Copies the ordered set.\n\n This is equivalent to:\n\n ```python\n order_set.create_unchecked(order_set)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set\n OrderedSet([1, 2, 3])\n >>> order_set.copy()\n OrderedSet([1, 2, 3])\n ```\n\n Returns:\n The copied ordered set.\n \"\"\"\n return self.create_unchecked(self)\n\n def __contains__(self, item: Any) -> bool:\n return item in self._item_to_index\n\n def add(self, item: Q) -> None:\n \"\"\"Adds an item to the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set\n OrderedSet()\n >>> order_set.add(0)\n >>> order_set.add(1)\n >>> order_set.add(0)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n item: The item to add.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item not in item_to_index:\n items = self._items\n\n item_to_index[item] = len(items)\n\n items.append(item)\n\n append = add\n \"\"\"An alias of [`add`][iters.ordered_set.OrderedSet.add].\"\"\"\n\n def update(self, iterable: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set with the items from an iterable.\n\n This is equivalent to:\n\n ```python\n for item in iterable:\n ordered_set.add(item)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set.update([0, 1])\n >>> order_set.update([1, 2, 3])\n >>> order_set\n OrderedSet([0, 1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to update the ordered set with.\n \"\"\"\n for item in iterable:\n self.add(item)\n\n extend = update\n \"\"\"An alias of [`update`][iters.ordered_set.OrderedSet.update].\"\"\"\n\n def index(self, item: Q, start: Optional[int] = None, stop: Optional[int] = None) -> int:\n \"\"\"Gets the index of an item in the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set.index(1)\n 0\n >>> order_set.index(5)\n Traceback (most recent call last):\n ...\n ValueError: 5 is not in the ordered set\n ```\n\n Arguments:\n item: The item to get the index of.\n start: The index to start searching from.\n stop: The index to stop searching at.\n\n Raises:\n ValueError: The item is not in the ordered set.\n\n Returns:\n The index of the item.\n \"\"\"\n index = self._item_to_index.get(item)\n error = item_not_in_ordered_set(item)\n\n if index is None:\n raise error\n\n if start is not None:\n if index < start:\n raise error\n\n if stop is not None:\n if index >= stop:\n raise error\n\n return index\n\n get_index = wrap_option(index)\n \"\"\"An alias of [`index`][iters.ordered_set.OrderedSet.index] wrapped to return\n [`Option[int]`][wraps.option.Option] instead of erroring.\n \"\"\"\n\n def count(self, item: Q) -> int:\n \"\"\"Returns `1` if an item is in the ordered set, `0` otherwise.\n\n Complexity:\n `O(1)`.\n\n Arguments:\n item: The item to count.\n\n Returns:\n `1` if the `item` is in the ordered set, `0` otherwise.\n \"\"\"\n return int(item in self._item_to_index)\n\n def pop(self, index: int = LAST) -> Q:\n \"\"\"Pops an item from the ordered set at `index`.\n\n Complexity:\n `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.pop()\n 1\n >>> order_set.pop(0)\n 0\n >>> order_set.pop()\n Traceback (most recent call last):\n ...\n IndexError: list index out of range\n ```\n\n Arguments:\n index: The index to pop the item from.\n\n Raises:\n IndexError: The index is out of range.\n\n Returns:\n The popped item.\n \"\"\"\n items = self._items\n\n item = items[index]\n\n self.discard(item)\n\n return item\n\n get_pop = wrap_option(pop)\n \"\"\"An alias of [`pop`][iters.ordered_set.OrderedSet.pop] wrapped to return\n [`Option[Q]`][wraps.option.Option] instead of erroring.\n \"\"\"\n\n def discard(self, item: Q) -> None:\n \"\"\"Discards an item from the ordered set.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the removed index must be decremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.discard(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.discard(1)\n >>> order_set.discard(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to discard.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n index = item_to_index[item]\n\n del self._items[index]\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] -= 1\n\n def remove(self, item: Q) -> None:\n \"\"\"A checked version of [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Complexity: `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.remove(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.remove(1)\n Traceback (most recent call last):\n ...\n ValueError: 1 is not in the ordered set\n >>> order_set.remove(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to remove.\n\n Raises:\n ValueError: The item is not in the ordered set.\n \"\"\"\n if item in self:\n self.discard(item)\n\n else:\n raise ValueError(ITEM_NOT_IN_ORDERED_SET.format(item))\n\n def insert(self, index: int, item: Q) -> None:\n \"\"\"Inserts an item into the ordered set at `index`.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the inserted index must be incremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 3])\n >>> order_set.insert(1, 2)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n index: The index to insert the item at.\n item: The item to insert.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n return\n\n items = self._items\n\n if index < len(items):\n items.insert(index, item)\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] += 1\n\n item_to_index[item] = index\n\n else:\n self.append(item)\n\n def clear(self) -> None:\n \"\"\"Clears the ordered set.\n\n Complexity:\n `O(1)`.\n \"\"\"\n self._items.clear()\n self._item_to_index.clear()\n\n def __iter__(self) -> Iterator[Q]:\n return iter(self._items)\n\n def __reversed__(self) -> Iterator[Q]:\n return reversed(self._items)\n\n def __repr__(self) -> str:\n name = get_type_name(self)\n\n items = self._items\n\n if not items:\n return EMPTY_REPRESENTATION.format(name)\n\n return ITEMS_REPRESENTATION.format(name, items)\n\n def __eq__(self, other: Any) -> bool:\n if is_instance(other, Iterable):\n if is_instance(other, Sequence):\n return self._items == list(other)\n\n return set(self._item_to_index) == set(other)\n\n return False\n\n def apply_union(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the union of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the union with.\n\n Returns:\n The union of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n return self.create_union(self, *iterables)\n\n return self.copy()\n\n union = mixed_method(create_union, apply_union)\n \"\"\"Mixes [`create_union`][iters.ordered_set.OrderedSet.create_union]\n and [`apply_union`][iters.ordered_set.OrderedSet.apply_union].\n \"\"\"\n\n def apply_intersection(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the intersection of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n\n Returns:\n The intersection of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n intersection = set.intersection(*map(set, iterables)) # type: ignore\n\n iterator = (item for item in self if item in intersection)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n\n intersection = mixed_method(create_intersection, apply_intersection)\n \"\"\"Mixes [`create_intersection`][iters.ordered_set.OrderedSet.create_intersection]\n and [`apply_intersection`][iters.ordered_set.OrderedSet.apply_intersection].\n \"\"\"\n\n def intersection_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the intersection of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n \"\"\"\n if iterables:\n intersection = self.intersection(*iterables)\n\n self.clear()\n\n self.update(intersection)\n\n def apply_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n\n Returns:\n The difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n union = set.union(*map(set, iterables)) # type: ignore\n iterator = (item for item in self if item not in union)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n\n difference = mixed_method(create_difference, apply_difference)\n \"\"\"Mixes [`create_difference`][iters.ordered_set.OrderedSet.create_difference]\n and [`apply_difference`][iters.ordered_set.OrderedSet.apply_difference].\n \"\"\"\n\n def difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n \"\"\"\n if iterables:\n difference = self.difference(*iterables)\n\n self.clear()\n\n self.update(difference)\n\n def single_symmetric_difference(self, other: Iterable[Q]) -> OrderedSet[Q]:\n ordered = self.create(other)\n\n return self.difference(ordered).union(ordered.difference(self))\n\n def apply_symmetric_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the symmetric difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n\n Returns:\n The symmetric difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n result = self\n\n for iterable in iterables:\n result = result.single_symmetric_difference(iterable)\n\n return result\n\n return self.copy()\n\n symmetric_difference = mixed_method(create_symmetric_difference, apply_symmetric_difference)\n \"\"\"Mixes\n [`create_symmetric_difference`][iters.ordered_set.OrderedSet.create_symmetric_difference] and\n [`apply_symmetric_difference`][iters.ordered_set.OrderedSet.apply_symmetric_difference].\n \"\"\"\n\n def symmetric_difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the symmetric difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n \"\"\"\n if iterables:\n symmetric_difference = self.symmetric_difference(*iterables)\n\n self.clear()\n\n self.update(symmetric_difference)\n\n def is_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a subset of.\n\n Returns:\n Whether the ordered set is a subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) > len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other)\n\n return len(self) <= len(other_set) and all(item in other_set for item in self)\n\n def is_strict_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict subset of.\n\n Returns:\n Whether the ordered set is a strict subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) >= len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other) # default case\n\n return len(self) < len(other_set) and all(item in other_set for item in self)\n\n def is_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a superset of.\n\n Returns:\n Whether the ordered set is a superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) >= len(other) and all(item in self for item in other)\n\n return all(item in self for item in other) # default case\n\n def is_strict_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict superset of.\n\n Returns:\n Whether the ordered set is a strict superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) > len(other) and all(item in self for item in other)\n\n array = list(other) # default case\n\n return len(self) > len(array) and all(item in self for item in array)\n\n def is_disjoint(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is disjoint with `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is disjoint with.\n\n Returns:\n Whether the ordered set is disjoint with `other`.\n \"\"\"\n return none(item in self for item in other)\n\n # I honestly hate these names ~ nekit\n\n issubset = is_subset\n issuperset = is_superset\n isdisjoint = is_disjoint\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.append","title":"append = add
class-attribute
instance-attribute
","text":"An alias of add
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.extend","title":"extend = update
class-attribute
instance-attribute
","text":"An alias of update
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.get_index","title":"get_index = wrap_option(index)
class-attribute
instance-attribute
","text":"An alias of index
wrapped to return Option[int]
instead of erroring.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.get_pop","title":"get_pop = wrap_option(pop)
class-attribute
instance-attribute
","text":"An alias of pop
wrapped to return Option[Q]
instead of erroring.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.union","title":"union = mixed_method(create_union, apply_union)
class-attribute
instance-attribute
","text":"Mixes create_union
and apply_union
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.intersection","title":"intersection = mixed_method(create_intersection, apply_intersection)
class-attribute
instance-attribute
","text":"Mixes create_intersection
and apply_intersection
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.difference","title":"difference = mixed_method(create_difference, apply_difference)
class-attribute
instance-attribute
","text":"Mixes create_difference
and apply_difference
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.symmetric_difference","title":"symmetric_difference = mixed_method(create_symmetric_difference, apply_symmetric_difference)
class-attribute
instance-attribute
","text":"Mixes create_symmetric_difference
and apply_symmetric_difference
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create","title":"create(iterable: Iterable[R] = ()) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set from an iterable.
Complexity O(n)
, where n
is the length of the iterable.
Example >>> array = [0, 1, 1, 0, 1, 1, 1, 0]\n>>> order_set = ordered_set.create(array)\n>>> order_set\nOrderedSet([0, 1])\n
Parameters:
Name Type Description Default iterable
Iterable[R]
The iterable to create the ordered set from.
()
Returns:
Type Description OrderedSet[R]
The created ordered set.
Source code in iters/ordered_set.py
@classmethod\ndef create(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [0, 1, 1, 0, 1, 1, 1, 0]\n >>> order_set = ordered_set.create(array)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n return cls(iterable) # type: ignore\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_unchecked","title":"create_unchecked(iterable: Iterable[R] = ()) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set from an iterable without checking if the items are unique.
This method is useful when constructing an ordered set from an iterable that is known to contain unique items only.
Complexity O(n)
, where n
is the length of the iterable.
Example >>> array = [1, 2, 3] # we know that the items are unique\n>>> order_set = ordered_set.create_unchecked(array)\n>>> order_set\nOrderedSet([1, 2, 3])\n
Parameters:
Name Type Description Default iterable
Iterable[R]
The iterable to create the ordered set from.
()
Returns:
Type Description OrderedSet[R]
The created ordered set.
Source code in iters/ordered_set.py
@classmethod\ndef create_unchecked(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable without checking if the items are unique.\n\n This method is useful when constructing an ordered set from an iterable that is known to\n contain unique items only.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [1, 2, 3] # we know that the items are unique\n >>> order_set = ordered_set.create_unchecked(array)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n self: OrderedSet[R] = cls.create()\n\n items = self._items\n item_to_index = self._item_to_index\n\n items.extend(iterable)\n\n for index, item in enumerate(items):\n item_to_index[item] = index\n\n return self\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_union","title":"create_union(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the union of given iterables.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the ordered set union from.
()
Returns:
Type Description OrderedSet[R]
The ordered set union.
Source code in iters/ordered_set.py
@classmethod\ndef create_union(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the union of given iterables.\n\n Arguments:\n *iterables: The iterables to create the ordered set union from.\n\n Returns:\n The ordered set union.\n \"\"\"\n return cls.create(chain(*iterables))\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_intersection","title":"create_intersection(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the intersection of given iterables.
The order is determined by the first iterable.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the ordered set intersection from.
()
Returns:
Type Description OrderedSet[R]
The ordered set intersection.
Source code in iters/ordered_set.py
@classmethod\ndef create_intersection(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the intersection of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set intersection from.\n\n Returns:\n The ordered set intersection.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_intersection(*tail)\n\n return cls.create()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_difference","title":"create_difference(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the difference of given iterables.
The order is determined by the first iterable.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the orderd set difference from.
()
Returns:
Type Description OrderedSet[R]
The ordered set difference.
Source code in iters/ordered_set.py
@classmethod\ndef create_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the orderd set difference from.\n\n Returns:\n The ordered set difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_difference(*tail)\n\n return cls.create()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_symmetric_difference","title":"create_symmetric_difference(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the symmetric difference of given iterables.
The order is determined by the first iterable.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the ordered set symmetric difference from.
()
Returns:
Type Description OrderedSet[R]
The ordered set symmetric difference.
Source code in iters/ordered_set.py
@classmethod\ndef create_symmetric_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the symmetric difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set symmetric difference from.\n\n Returns:\n The ordered set symmetric difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_symmetric_difference(*tail)\n\n return cls.create()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.copy","title":"copy() -> OrderedSet[Q]
","text":"Copies the ordered set.
This is equivalent to:
order_set.create_unchecked(order_set)\n
Complexity O(n)
, where n
is the length of the ordered set.
Example >>> order_set = ordered_set([1, 2, 3])\n>>> order_set\nOrderedSet([1, 2, 3])\n>>> order_set.copy()\nOrderedSet([1, 2, 3])\n
Returns:
Type Description OrderedSet[Q]
The copied ordered set.
Source code in iters/ordered_set.py
def copy(self) -> OrderedSet[Q]:\n \"\"\"Copies the ordered set.\n\n This is equivalent to:\n\n ```python\n order_set.create_unchecked(order_set)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set\n OrderedSet([1, 2, 3])\n >>> order_set.copy()\n OrderedSet([1, 2, 3])\n ```\n\n Returns:\n The copied ordered set.\n \"\"\"\n return self.create_unchecked(self)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.add","title":"add(item: Q) -> None
","text":"Adds an item to the ordered set.
Complexity O(1)
.
Example >>> order_set = ordered_set()\n>>> order_set\nOrderedSet()\n>>> order_set.add(0)\n>>> order_set.add(1)\n>>> order_set.add(0)\n>>> order_set\nOrderedSet([0, 1])\n
Parameters:
Name Type Description Default item
Q
The item to add.
required Source code in iters/ordered_set.py
def add(self, item: Q) -> None:\n \"\"\"Adds an item to the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set\n OrderedSet()\n >>> order_set.add(0)\n >>> order_set.add(1)\n >>> order_set.add(0)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n item: The item to add.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item not in item_to_index:\n items = self._items\n\n item_to_index[item] = len(items)\n\n items.append(item)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.update","title":"update(iterable: Iterable[Q]) -> None
","text":"Updates the ordered set with the items from an iterable.
This is equivalent to:
for item in iterable:\n ordered_set.add(item)\n
Complexity O(n)
, where n
is the length of the iterable.
Example >>> order_set = ordered_set()\n>>> order_set.update([0, 1])\n>>> order_set.update([1, 2, 3])\n>>> order_set\nOrderedSet([0, 1, 2, 3])\n
Parameters:
Name Type Description Default iterable
Iterable[Q]
The iterable to update the ordered set with.
required Source code in iters/ordered_set.py
def update(self, iterable: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set with the items from an iterable.\n\n This is equivalent to:\n\n ```python\n for item in iterable:\n ordered_set.add(item)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set.update([0, 1])\n >>> order_set.update([1, 2, 3])\n >>> order_set\n OrderedSet([0, 1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to update the ordered set with.\n \"\"\"\n for item in iterable:\n self.add(item)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.index","title":"index(item: Q, start: Optional[int] = None, stop: Optional[int] = None) -> int
","text":"Gets the index of an item in the ordered set.
Complexity O(1)
.
Example >>> order_set = ordered_set([1, 2, 3])\n>>> order_set.index(1)\n0\n>>> order_set.index(5)\nTraceback (most recent call last):\n ...\nValueError: 5 is not in the ordered set\n
Parameters:
Name Type Description Default item
Q
The item to get the index of.
required start
Optional[int]
The index to start searching from.
None
stop
Optional[int]
The index to stop searching at.
None
Raises:
Type Description ValueError
The item is not in the ordered set.
Returns:
Type Description int
The index of the item.
Source code in iters/ordered_set.py
def index(self, item: Q, start: Optional[int] = None, stop: Optional[int] = None) -> int:\n \"\"\"Gets the index of an item in the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set.index(1)\n 0\n >>> order_set.index(5)\n Traceback (most recent call last):\n ...\n ValueError: 5 is not in the ordered set\n ```\n\n Arguments:\n item: The item to get the index of.\n start: The index to start searching from.\n stop: The index to stop searching at.\n\n Raises:\n ValueError: The item is not in the ordered set.\n\n Returns:\n The index of the item.\n \"\"\"\n index = self._item_to_index.get(item)\n error = item_not_in_ordered_set(item)\n\n if index is None:\n raise error\n\n if start is not None:\n if index < start:\n raise error\n\n if stop is not None:\n if index >= stop:\n raise error\n\n return index\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.count","title":"count(item: Q) -> int
","text":"Returns 1
if an item is in the ordered set, 0
otherwise.
Complexity O(1)
.
Parameters:
Name Type Description Default item
Q
The item to count.
required Returns:
Type Description int
1
if the item
is in the ordered set, 0
otherwise.
Source code in iters/ordered_set.py
def count(self, item: Q) -> int:\n \"\"\"Returns `1` if an item is in the ordered set, `0` otherwise.\n\n Complexity:\n `O(1)`.\n\n Arguments:\n item: The item to count.\n\n Returns:\n `1` if the `item` is in the ordered set, `0` otherwise.\n \"\"\"\n return int(item in self._item_to_index)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.pop","title":"pop(index: int = LAST) -> Q
","text":"Pops an item from the ordered set at index
.
Complexity O(n)
, see discard
.
Example >>> order_set = ordered_set([0, 1])\n>>> order_set.pop()\n1\n>>> order_set.pop(0)\n0\n>>> order_set.pop()\nTraceback (most recent call last):\n ...\nIndexError: list index out of range\n
Parameters:
Name Type Description Default index
int
The index to pop the item from.
LAST
Raises:
Type Description IndexError
The index is out of range.
Returns:
Type Description Q
The popped item.
Source code in iters/ordered_set.py
def pop(self, index: int = LAST) -> Q:\n \"\"\"Pops an item from the ordered set at `index`.\n\n Complexity:\n `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.pop()\n 1\n >>> order_set.pop(0)\n 0\n >>> order_set.pop()\n Traceback (most recent call last):\n ...\n IndexError: list index out of range\n ```\n\n Arguments:\n index: The index to pop the item from.\n\n Raises:\n IndexError: The index is out of range.\n\n Returns:\n The popped item.\n \"\"\"\n items = self._items\n\n item = items[index]\n\n self.discard(item)\n\n return item\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.discard","title":"discard(item: Q) -> None
","text":"Discards an item from the ordered set.
Complexity O(n)
, where n
is the length of the ordered set. This is because all indices after the removed index must be decremented.
Example >>> order_set = ordered_set([0, 1])\n>>> order_set.discard(1)\n>>> order_set\nOrderedSet([0])\n>>> order_set.discard(1)\n>>> order_set.discard(0)\n>>> order_set\nOrderedSet()\n
Parameters:
Name Type Description Default item
Q
The item to discard.
required Source code in iters/ordered_set.py
def discard(self, item: Q) -> None:\n \"\"\"Discards an item from the ordered set.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the removed index must be decremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.discard(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.discard(1)\n >>> order_set.discard(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to discard.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n index = item_to_index[item]\n\n del self._items[index]\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] -= 1\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.remove","title":"remove(item: Q) -> None
","text":"A checked version of discard
.
Complexity: O(n)
, see discard
.
Example >>> order_set = ordered_set([0, 1])\n>>> order_set.remove(1)\n>>> order_set\nOrderedSet([0])\n>>> order_set.remove(1)\nTraceback (most recent call last):\n ...\nValueError: 1 is not in the ordered set\n>>> order_set.remove(0)\n>>> order_set\nOrderedSet()\n
Parameters:
Name Type Description Default item
Q
The item to remove.
required Raises:
Type Description ValueError
The item is not in the ordered set.
Source code in iters/ordered_set.py
def remove(self, item: Q) -> None:\n \"\"\"A checked version of [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Complexity: `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.remove(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.remove(1)\n Traceback (most recent call last):\n ...\n ValueError: 1 is not in the ordered set\n >>> order_set.remove(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to remove.\n\n Raises:\n ValueError: The item is not in the ordered set.\n \"\"\"\n if item in self:\n self.discard(item)\n\n else:\n raise ValueError(ITEM_NOT_IN_ORDERED_SET.format(item))\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.insert","title":"insert(index: int, item: Q) -> None
","text":"Inserts an item into the ordered set at index
.
Complexity O(n)
, where n
is the length of the ordered set. This is because all indices after the inserted index must be incremented.
Example >>> order_set = ordered_set([1, 3])\n>>> order_set.insert(1, 2)\n>>> order_set\nOrderedSet([1, 2, 3])\n
Parameters:
Name Type Description Default index
int
The index to insert the item at.
required item
Q
The item to insert.
required Source code in iters/ordered_set.py
def insert(self, index: int, item: Q) -> None:\n \"\"\"Inserts an item into the ordered set at `index`.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the inserted index must be incremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 3])\n >>> order_set.insert(1, 2)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n index: The index to insert the item at.\n item: The item to insert.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n return\n\n items = self._items\n\n if index < len(items):\n items.insert(index, item)\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] += 1\n\n item_to_index[item] = index\n\n else:\n self.append(item)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.clear","title":"clear() -> None
","text":"Clears the ordered set.
Complexity O(1)
.
Source code in iters/ordered_set.py
def clear(self) -> None:\n \"\"\"Clears the ordered set.\n\n Complexity:\n `O(1)`.\n \"\"\"\n self._items.clear()\n self._item_to_index.clear()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_union","title":"apply_union(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the union of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the union with.
()
Returns:
Type Description OrderedSet[Q]
The union of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_union(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the union of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the union with.\n\n Returns:\n The union of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n return self.create_union(self, *iterables)\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_intersection","title":"apply_intersection(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the intersection of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the intersection with.
()
Returns:
Type Description OrderedSet[Q]
The intersection of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_intersection(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the intersection of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n\n Returns:\n The intersection of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n intersection = set.intersection(*map(set, iterables)) # type: ignore\n\n iterator = (item for item in self if item in intersection)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.intersection_update","title":"intersection_update(*iterables: Iterable[Q]) -> None
","text":"Updates the ordered set to be the intersection of itself and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the intersection with.
()
Source code in iters/ordered_set.py
def intersection_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the intersection of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n \"\"\"\n if iterables:\n intersection = self.intersection(*iterables)\n\n self.clear()\n\n self.update(intersection)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_difference","title":"apply_difference(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the difference of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the difference with.
()
Returns:
Type Description OrderedSet[Q]
The difference of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n\n Returns:\n The difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n union = set.union(*map(set, iterables)) # type: ignore\n iterator = (item for item in self if item not in union)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.difference_update","title":"difference_update(*iterables: Iterable[Q]) -> None
","text":"Updates the ordered set to be the difference of itself and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the difference with.
()
Source code in iters/ordered_set.py
def difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n \"\"\"\n if iterables:\n difference = self.difference(*iterables)\n\n self.clear()\n\n self.update(difference)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_symmetric_difference","title":"apply_symmetric_difference(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the symmetric difference of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the symmetric difference with.
()
Returns:
Type Description OrderedSet[Q]
The symmetric difference of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_symmetric_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the symmetric difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n\n Returns:\n The symmetric difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n result = self\n\n for iterable in iterables:\n result = result.single_symmetric_difference(iterable)\n\n return result\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.symmetric_difference_update","title":"symmetric_difference_update(*iterables: Iterable[Q]) -> None
","text":"Updates the ordered set to be the symmetric difference of itself and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the symmetric difference with.
()
Source code in iters/ordered_set.py
def symmetric_difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the symmetric difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n \"\"\"\n if iterables:\n symmetric_difference = self.symmetric_difference(*iterables)\n\n self.clear()\n\n self.update(symmetric_difference)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_subset","title":"is_subset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a subset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a subset of.
required Returns:
Type Description bool
Whether the ordered set is a subset of other
.
Source code in iters/ordered_set.py
def is_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a subset of.\n\n Returns:\n Whether the ordered set is a subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) > len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other)\n\n return len(self) <= len(other_set) and all(item in other_set for item in self)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_strict_subset","title":"is_strict_subset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a strict subset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a strict subset of.
required Returns:
Type Description bool
Whether the ordered set is a strict subset of other
.
Source code in iters/ordered_set.py
def is_strict_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict subset of.\n\n Returns:\n Whether the ordered set is a strict subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) >= len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other) # default case\n\n return len(self) < len(other_set) and all(item in other_set for item in self)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_superset","title":"is_superset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a superset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a superset of.
required Returns:
Type Description bool
Whether the ordered set is a superset of other
.
Source code in iters/ordered_set.py
def is_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a superset of.\n\n Returns:\n Whether the ordered set is a superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) >= len(other) and all(item in self for item in other)\n\n return all(item in self for item in other) # default case\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_strict_superset","title":"is_strict_superset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a strict superset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a strict superset of.
required Returns:
Type Description bool
Whether the ordered set is a strict superset of other
.
Source code in iters/ordered_set.py
def is_strict_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict superset of.\n\n Returns:\n Whether the ordered set is a strict superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) > len(other) and all(item in self for item in other)\n\n array = list(other) # default case\n\n return len(self) > len(array) and all(item in self for item in array)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_disjoint","title":"is_disjoint(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is disjoint with other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is disjoint with.
required Returns:
Type Description bool
Whether the ordered set is disjoint with other
.
Source code in iters/ordered_set.py
def is_disjoint(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is disjoint with `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is disjoint with.\n\n Returns:\n Whether the ordered set is disjoint with `other`.\n \"\"\"\n return none(item in self for item in other)\n
"},{"location":"reference/types/","title":"Types","text":""},{"location":"reference/types/#iters.types.no_default","title":"no_default = NoDefault()
module-attribute
","text":"The instance of NoDefault
.
"},{"location":"reference/types/#iters.types.marker","title":"marker = Marker()
module-attribute
","text":"The instance of Marker
.
"},{"location":"reference/types/#iters.types.NoDefault","title":"NoDefault
","text":" Bases: Singleton
Represents the absence of default values.
Source code in iters/types.py
class NoDefault(Singleton):\n \"\"\"Represents the absence of default values.\"\"\"\n
"},{"location":"reference/types/#iters.types.Marker","title":"Marker
","text":" Bases: Singleton
Represents markers used for various checks.
Source code in iters/types.py
class Marker(Singleton):\n \"\"\"Represents markers used for various checks.\"\"\"\n
"},{"location":"reference/types/#iters.types.is_no_default","title":"is_no_default(item: Any) -> TypeGuard[NoDefault]
","text":"Checks if the item
is NoDefault
.
Returns:
Type Description TypeGuard[NoDefault]
Whether the item
is NoDefault
.
Source code in iters/types.py
def is_no_default(item: Any) -> TypeGuard[NoDefault]:\n \"\"\"Checks if the `item` is [`NoDefault`][iters.types.NoDefault].\n\n Returns:\n Whether the `item` is [`NoDefault`][iters.types.NoDefault].\n \"\"\"\n return item is no_default\n
"},{"location":"reference/types/#iters.types.is_not_no_default","title":"is_not_no_default(item: NoDefaultOr[T]) -> TypeGuard[T]
","text":"Checks if the item
is not NoDefault
.
Returns:
Type Description TypeGuard[T]
Whether the item
is not NoDefault
.
Source code in iters/types.py
def is_not_no_default(item: NoDefaultOr[T]) -> TypeGuard[T]:\n \"\"\"Checks if the `item` is not [`NoDefault`][iters.types.NoDefault].\n\n Returns:\n Whether the `item` is not [`NoDefault`][iters.types.NoDefault].\n \"\"\"\n return item is not no_default\n
"},{"location":"reference/types/#iters.types.is_marker","title":"is_marker(item: Any) -> TypeGuard[Marker]
","text":"Checks if the item
is Marker
.
Returns:
Type Description TypeGuard[Marker]
Whether the item
is Marker
.
Source code in iters/types.py
def is_marker(item: Any) -> TypeGuard[Marker]:\n \"\"\"Checks if the `item` is [`Marker`][iters.types.Marker].\n\n Returns:\n Whether the `item` is [`Marker`][iters.types.Marker].\n \"\"\"\n return item is marker\n
"},{"location":"reference/types/#iters.types.is_not_marker","title":"is_not_marker(item: MarkerOr[T]) -> TypeGuard[T]
","text":"Checks if the item
is not Marker
.
Returns:
Type Description TypeGuard[T]
Whether the item
is not Marker
.
Source code in iters/types.py
def is_not_marker(item: MarkerOr[T]) -> TypeGuard[T]:\n \"\"\"Checks if the `item` is not [`Marker`][iters.types.Marker].\n\n Returns:\n Whether the `item` is not [`Marker`][iters.types.Marker].\n \"\"\"\n return item is not marker\n
"},{"location":"reference/typing/","title":"Typing","text":""},{"location":"reference/typing/#iters.typing.Sum","title":"Sum
","text":" Bases: Protocol
Represents types for which adding self: S
to other: S
returns S
.
Source code in iters/typing.py
@runtime_checkable\nclass Sum(Protocol):\n \"\"\"Represents types for which adding `self: S` to `other: S` returns `S`.\"\"\"\n\n @required\n def __add__(self: S, __other: S) -> S:\n raise NotImplementedError\n
"},{"location":"reference/typing/#iters.typing.Product","title":"Product
","text":" Bases: Protocol
Represents types for which multiplying self: P
with other: P
returns P
.
Source code in iters/typing.py
@runtime_checkable\nclass Product(Protocol):\n \"\"\"Represents types for which multiplying `self: P` with `other: P` returns `P`.\"\"\"\n\n @required\n def __mul__(self: P, __other: P) -> P:\n raise NotImplementedError\n
"},{"location":"reference/utils/","title":"Utilities","text":""}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"iters
","text":"Composable external iteration.
If you have found yourself with a collection of some kind, and needed to perform an operation on the elements of said collection, you will quickly run into iterators. Iterators are heavily used in idiomatic Python code, so becoming familiar with them is essential.
"},{"location":"#installing","title":"Installing","text":"Python 3.8 or above is required.
"},{"location":"#pip","title":"pip","text":"Installing the library with pip
is quite simple:
$ pip install iters\n
Alternatively, the library can be installed from source:
$ git clone https://github.com/nekitdev/iters.git\n$ cd iters\n$ python -m pip install .\n
"},{"location":"#poetry","title":"poetry","text":"You can add iters
as a dependency with the following command:
$ poetry add iters\n
Or by directly specifying it in the configuration like so:
[tool.poetry.dependencies]\niters = \"^0.15.0\"\n
Alternatively, you can add it directly from the source:
[tool.poetry.dependencies.iters]\ngit = \"https://github.com/nekitdev/iters.git\"\n
"},{"location":"#examples","title":"Examples","text":""},{"location":"#simple","title":"Simple","text":"Squaring only even numbers in some sequence:
from iters import iter\n\n\ndef is_even(value: int) -> bool:\n return not value % 2\n\n\ndef square(value: int) -> int:\n return value * value\n\n\nnumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n\nresult = iter(numbers).filter(is_even).map(square).list()\n\nprint(result) # [0, 4, 16, 36, 64]\n
"},{"location":"#asynchronous","title":"Asynchronous","text":"Asynchronous iteration is fully supported by iters
, and its API is similar to its synchronous counterpart.
"},{"location":"#documentation","title":"Documentation","text":"You can find the documentation here.
"},{"location":"#support","title":"Support","text":"If you need support with the library, you can send an email or refer to the official Discord server.
"},{"location":"#changelog","title":"Changelog","text":"You can find the changelog here.
"},{"location":"#security-policy","title":"Security Policy","text":"You can find the Security Policy of iters
here.
"},{"location":"#contributing","title":"Contributing","text":"If you are interested in contributing to iters
, make sure to take a look at the Contributing Guide, as well as the Code of Conduct.
"},{"location":"#license","title":"License","text":"iters
is licensed under the MIT License terms. See License for details.
"},{"location":"changelog/","title":"Changelog","text":""},{"location":"changelog/#0150-2023-12-01","title":"0.15.0 (2023-12-01)","text":""},{"location":"changelog/#changes","title":"Changes","text":" - Changed
reduce
and reduce_await
on Iter[T]
and AsyncIter[T]
to return Option[T]
instead of erroring on empty iterators.
"},{"location":"changelog/#internal","title":"Internal","text":" - Changed
variable is marker
and variable is no_default
to is_marker(variable)
and is_no_default(variable)
respectively.
"},{"location":"changelog/#0141-2023-12-01","title":"0.14.1 (2023-12-01)","text":"No significant changes.
"},{"location":"changelog/#0140-2023-12-01","title":"0.14.0 (2023-12-01)","text":""},{"location":"changelog/#internal_1","title":"Internal","text":" - Migrated to Python 3.8.
"},{"location":"changelog/#0131-2023-05-24","title":"0.13.1 (2023-05-24)","text":""},{"location":"changelog/#fixes","title":"Fixes","text":" - Fixed
final
import to be compatible with Python 3.7.
"},{"location":"changelog/#0130-2023-05-21","title":"0.13.0 (2023-05-21)","text":""},{"location":"changelog/#internal_2","title":"Internal","text":" - Migrated to using
typing-aliases
library.
"},{"location":"changelog/#0120-2023-05-10","title":"0.12.0 (2023-05-10)","text":""},{"location":"changelog/#changes_1","title":"Changes","text":" - This release contains lots of breaking changes. Please refer to the API documentation.
"},{"location":"changelog/#0110-2023-01-29","title":"0.11.0 (2023-01-29)","text":""},{"location":"changelog/#internal_3","title":"Internal","text":" async-extensions
is now used instead of reimplementing collect_iterable
functionality.
"},{"location":"changelog/#0100-2023-01-08","title":"0.10.0 (2023-01-08)","text":""},{"location":"changelog/#internal_4","title":"Internal","text":" - Marked the internals of the
OrderedSet[Q]
private.
"},{"location":"changelog/#090-2023-01-07","title":"0.9.0 (2023-01-07)","text":""},{"location":"changelog/#features","title":"Features","text":" - Added
collect_iter
method for AsyncIter[T]
and Iter[T]
.
"},{"location":"changelog/#080-2022-12-22","title":"0.8.0 (2022-12-22)","text":""},{"location":"changelog/#features_1","title":"Features","text":" - Added
into_iter
method for AsyncIter[T]
. - Added
into_async_iter
method for Iter[T]
.
"},{"location":"changelog/#070-2022-12-20","title":"0.7.0 (2022-12-20)","text":""},{"location":"changelog/#features_2","title":"Features","text":" - Added
OrderedSet[Q]
type within the iters.ordered_set
module. - Added
ordered_set
method to Iter[T]
and AsyncIter[T]
.
"},{"location":"changelog/#060-2022-11-08","title":"0.6.0 (2022-11-08)","text":""},{"location":"changelog/#internal_5","title":"Internal","text":" - Migrated to using
named
and solus
packages instead of reimplementing their functionality. (#18)
"},{"location":"changelog/#050-2022-10-11","title":"0.5.0 (2022-10-11)","text":""},{"location":"changelog/#changes_2","title":"Changes","text":" - Functions taking
Predicate[T]
have been updated to accept Optional[Predicate[T]]
. Passing None
as an argument is identical to passing bool
.
There are three functions which do not accept None
, though: - drop_while
- skip_while
- take_while
This choice is motivated by the fact that it does not make much sense to do_while(None)
.
"},{"location":"changelog/#040-2022-10-08","title":"0.4.0 (2022-10-08)","text":""},{"location":"changelog/#changes_3","title":"Changes","text":" - The following functions have been changed:
async_iter
is now an alias of AsyncIter
; iter
is now an alias of Iter
; reversed
is now an alias of iter.reversed
.
"},{"location":"changelog/#030-2022-08-17","title":"0.3.0 (2022-08-17)","text":""},{"location":"changelog/#changes_4","title":"Changes","text":" - Changed functions of various arity returning
Awaitable[T]
to async functions returning T
. (#15)
"},{"location":"changelog/#020-2022-08-15","title":"0.2.0 (2022-08-15)","text":""},{"location":"changelog/#changes_5","title":"Changes","text":" - Added
await async_iter
, equivalent to await async_iter.list()
.
"},{"location":"changelog/#010-2022-08-01","title":"0.1.0 (2022-08-01)","text":"Initial release.
"},{"location":"code_of_conduct/","title":"Code of Conduct","text":""},{"location":"code_of_conduct/#our-pledge","title":"Our Pledge","text":"We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
"},{"location":"code_of_conduct/#our-standards","title":"Our Standards","text":"Examples of behavior that contributes to a positive environment for our community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
"},{"location":"code_of_conduct/#enforcement-responsibilities","title":"Enforcement Responsibilities","text":"Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
"},{"location":"code_of_conduct/#scope","title":"Scope","text":"This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
"},{"location":"code_of_conduct/#enforcement","title":"Enforcement","text":"Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement to conduct@nekit.dev.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
"},{"location":"code_of_conduct/#enforcement-guidelines","title":"Enforcement Guidelines","text":"Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
"},{"location":"code_of_conduct/#1-correction","title":"1. Correction","text":"Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
"},{"location":"code_of_conduct/#2-warning","title":"2. Warning","text":"Community Impact: A violation through a single incident or series of actions.
Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
"},{"location":"code_of_conduct/#3-temporary-ban","title":"3. Temporary Ban","text":"Community Impact: A serious violation of community standards, including sustained inappropriate behavior.
Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
"},{"location":"code_of_conduct/#4-permanent-ban","title":"4. Permanent Ban","text":"Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
Consequence: A permanent ban from any sort of public interaction within the community.
"},{"location":"code_of_conduct/#attribution","title":"Attribution","text":"This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://contributor-covenant.org/version/2/1/code_of_conduct.
Community Impact Guidelines were inspired by Mozilla's Code of Conduct enforcement ladder.
For answers to common questions about this code of conduct, see the FAQ at https://contributor-covenant.org/faq. Translations are available at https://contributor-covenant.org/translations.
"},{"location":"predicates/","title":"Predicates","text":"iters
defines all predicate
arguments as Optional[Predicate[T]]
where T
is the item type of the iterable.
Passing None
as the predicate argument is equivalent to passing bool
, though most functions are optimized to avoid the overhead of function calls to it.
"},{"location":"security/","title":"Security Policy","text":""},{"location":"security/#reporting","title":"Reporting","text":"Thank you for taking the time to responsibly disclose any problems you find.
Do not file public issues as they are open for everyone to see!
All security vulnerabilities in iters
should be reported by email to security@nekit.dev. Your report will be acknowledged within 24 hours, and you will receive a more detailed response within 48 hours indicating the next steps in handling your report.
You can encrypt your report using our public key: 6AF9DDF87B37BBE6E83F5DF2B8F5B86F98F12F5E
. This key is also available on MIT's Key Server and reproduced below.
After the initial reply to your report, the core team will try to keep you informed of the progress being made towards a fix and official announcement. These updates will be sent at least every five days. In reality, this is more likely to be every 24-48 hours.
"},{"location":"security/#disclosure-policy","title":"Disclosure Policy","text":"iters
has a 5-step disclosure process:
-
The security report is received and is assigned a primary handler. This person will coordinate the fix and release process.
-
The problem is confirmed and a list of all affected versions is determined.
-
Code is audited to find any potential similar problems.
-
Fixes are prepared for all releases which are still under maintenance. These fixes are not committed to the public repository but rather held locally pending the announcement.
-
On the embargo date, the changes are pushed to the public repository and new builds are deployed.
This process can take some time, especially when coordination is required with maintainers of other projects. Every effort will be made to handle the issue in as timely a manner as possible, however it is important that we follow the release process above to ensure that the disclosure is handled in a consistent manner.
"},{"location":"security/#security-key","title":"Security Key","text":"-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGVV4JcBEAC7PTswfzA2iMTVSig51NVDV08XABrR01qslTfhIVw6Uwr2iCoY\nF+hkNn3++pgoF95Fx/iREDFV/AG4GGKl1GbAI3YD6aOoh0FGWtxg3MMa3oHjRUZs\nf0VwKk8sA5d21V05OiMuptAqxXuLrdR5SINtxKE10H6K9o22988VOmWUCIEaxKM5\nM5HCfhe8fl5pKpdIf3i1F073qset4DXGkvm/v+dWYHPvv0NlHhnJ5Lcaq4aTvkEg\ny2NhDobR4VpdP1aQZbEONussUaKLxBTBJN5NNnf7SI1qVYcaglYrXM7uQGXuL32X\nXAILtOCM0LO2059Z7ZMkI6lkkbei1j08j2Tha/1GvN2rIClNyV912GvAQhzlwhdT\nWmk+ymrwbed7MkRW3IB3b1zFb7Dhz6a5yBS8iT5ikkrGaR/i7O3V/DS02j7Rao2k\nnfXIncuBuXSXb1pIhCuYuV6VYBgFWfpKDjOzEy83h3DSI/jrR31e6aiBes+fyFRG\nIuoFRTsaMq2T9M5F6pDvmtoexHxXevYoSt+7DURY1pSWnk4MjZUj7yDFPSyfPleZ\naNq/3aGQt7vnY5QgyGjKaX5jSVuNEKsUlhrKUWt9weoJrF5ZyYHY0RPg1q1Fz0mY\nZ7QWeaKA0uOeziG0bHf6yNEzxnaYCfi09/WOL4GH0pBsdubNHpWno/D6PwARAQAB\ntC9OaWtpdGEgVGlraG9ub3YgKHNlY3VyaXR5KSA8c2VjdXJpdHlAbmVraXQuZGV2\nPokCTgQTAQoAOBYhBGr53fh7N7vm6D9d8rj1uG+Y8S9eBQJlVeCXAhsDBQsJCAcC\nBhUKCQgLAgQWAgMBAh4BAheAAAoJELj1uG+Y8S9ed4kP+wYE1OZtcWoRSK2Xqvaf\nP5+YcXC1vdCZ16depb6kGOR91G9eEMJhSDlSzzUzOmkvT4TknZi/Y17m9TvQccET\nSwgWvDs9XwMby24mkxD1iYu2uIZXXhRbIKJPi4EpGgamEveYLLTd0L8yX2l/YXuq\nVcM4vqgRtnovlW+cCUmmtpRcb+Ldfxu2RixjnG4fznzzlMOnU0zpWUMBqH+mSyfH\nRmY5vgOR/adgQcIviQdhRPMC4TAa3GNdTd2Qpxo3xelum15yLKxkm/EvBSPsL1fj\nJQBYnZFk4KBKNiXXYwWuU0mpOx1TMtYPVnHer17QL0vXfsmVNkXVzucvrNfHpFc9\nhXzmm5wHwMrGClyQBA6sDWDfQOKYibQTcKzyJr2Gl31luNPSRchzC4lbosLzRkqh\nYh5dco+ITiKDe7g54w+Fy+KdumwN/GvBlQptGIpaxA1+xAbNVs+fDo+WrQEL+AZO\nOQR91YUsjIdvVdk5BcgUYvEe2YyyMZ7LSqWACpRknqz5FNcdmO2bz7jl732EYLRm\nQ90oSG6xcIFuPZRNVIUJds9Gg2u1PBV5z0vnFGiJ6NK6DrYYecMKU9uAQUZcSW8v\n+fn92V0DkVeOfeMbq4yytZx5W4VrsWT1XyfjTzg867jzmo1JmZQeZ4KXh7AYRlC6\nn8NwYZ13+pUFeTPm9jCwJMrGuQINBGVV4JcBEACg5zXucth9KIdryYUxyBgA7Ist\nhJmyxtSHSiKRFOiQBmQqHeQgDdCnBeDw+cb+8wB4NL3PNw5xHKRvQGTWaBTV1IPf\nCV3P2c/sZLDCU8PNMu3lsmEbN2ippOiJi1fw478EGlNity8ktI+TEhsdniypKoiw\nDNf3wdawWiraODM9KuYplcsnFHl5r97BjHR0EbOOKkTc4PwysQ7WVHZ/nwGzNb5T\nCI7A/TF0RTL/Wkdz7WZM7r5BELz+z0ksjsS8eMObtm/uG4lfAmbIGohPTlir4WWL\n/GYZpAjvv/6zNaydMpY3uQKrdqN05j10uYnkbsclwSBBbRovFBRWEInbO0cqpzc0\nJiWt4U91F6UNbSDPo3KaiDjJXDb7cr4gQv0C1T9LtmKSfY/JVcUj7csGXslOAvXf\nz08iDCJu3zj7QjZPKA1/MxmTo88hAvhHlOYrXaaRjzXt6r9+qdDxVYJGe9K3LkJS\n9Yc0U9xBGAfzw9Ebs/ZPDtjgupPHJXq6VBSndU3c53jr7SEZBIFMPg75CeJJ6IgH\nA4zwW1uzalZi3mYWWCKiGhDBPOo5yGwKocxMzSuerlMW21fjhOMymSKVksteJlmZ\nAy6ExDNOK663V6iFnsn4iIFbE1jOznHhSsbyKqQ/QukpMqAyrQVSNyutXVl0VuW0\nZsZeFff7ScnrTgB7/QARAQABiQI2BBgBCgAgFiEEavnd+Hs3u+boP13yuPW4b5jx\nL14FAmVV4JcCGwwACgkQuPW4b5jxL15jNw/9EQkahEieTABEKAKxGetODA7HTiNR\ncM3aKgDU0msYjfgfAi+wQzx/8k8Yf/Kjma6JqsksCj0ygFkXS87tOAUfJTpgmKVS\nV3XaDXFwTcdG0+/Cx5RllduJmnLTLSuvm2uxu7ErPGtnYWBw88nmQ/8f9nkmvCsY\nCuF6DHAUNzTLgerFKSGNMwOv6kKBCgNkstclcHp5YbzssN1w34dPV/swuCjc+6JM\nnW5WuPD3R2Y9522Ov/bEwr9raFf3R5A6ETK4GOZUqNmPG4MJgbyiJlk96TuF06mO\nnFpKnBtxD+t20jAFTMRokyiQT65X8KnrpT8CpTJ6xzmBO5IYGhUSqt3CH/YzwqRa\nv9FTJ/qSPM5OXPH4pK7VzNDVhEPQhLAGENLwOnasnXXGvj/MQIRYyjGAXQfB34a7\nz0x4rQ+fyaody6BW10KJBQuRrB3dPaOPU3LU/4TxzyudDxiOJGiWAlw56a2lviEG\nJExMJrSvP5kiCfPlLZiLfqaw2ZYeyosnv8bmC4H2Sr9IEggtCyrzNOoJQx+w/f/L\n6a14Cshc3UYLC+0yh74Mc5vUu2SfwI6zSevjI1LWj4qc592J/q3QNHiJN9F60tyP\nr46uNM25Y+C5qgVneqRjHmWSIdOvYXcBTLj03eDiQHCJz3ZT6ztLwQxQ800MS1Yd\npbmAGLbBB2TBok4=\n=Ir8m\n-----END PGP PUBLIC KEY BLOCK-----\n
"},{"location":"security/#attribution","title":"Attribution","text":"This Security Policy is adapted from Rust's Security Policy.
"},{"location":"reference/async_iters/","title":"Async Iterators","text":""},{"location":"reference/async_iters/#iters.async_iters.AsyncIter","title":"AsyncIter
","text":" Bases: AsyncIterator[T]
Source code in iters/async_iters.py
class AsyncIter(AsyncIterator[T]):\n # internals\n\n _iterator: AsyncIterator[T]\n\n def __init__(self, iterable: AnyIterable[T]) -> None:\n self._iterator = async_iter_any_iter(iterable)\n\n def _replace(self, iterator: AsyncIterator[T]) -> None:\n self._iterator = iterator\n\n # implementation\n\n @property\n def iterator(self) -> AsyncIterator[T]:\n \"\"\"The underlying iterator.\"\"\"\n return self._iterator\n\n @classmethod\n def empty(cls) -> AsyncIter[T]:\n return cls.create(async_empty())\n\n @classmethod\n def of(cls, *items: V) -> AsyncIter[V]:\n return cls.create(async_of(*items))\n\n @classmethod\n def once(cls, value: V) -> AsyncIter[V]:\n return cls.create(async_once(value))\n\n @classmethod\n def once_with(cls, function: Nullary[V]) -> AsyncIter[V]:\n return cls.create(async_once_with(function))\n\n @classmethod\n def once_with_await(cls, function: AsyncNullary[V]) -> AsyncIter[V]:\n return cls.create(async_once_with_await(function))\n\n @classmethod\n def repeat(cls, value: V) -> AsyncIter[V]:\n return cls.create(async_repeat(value))\n\n @classmethod\n def repeat_exactly(cls, value: V, count: int) -> AsyncIter[V]:\n return cls.create(async_repeat(value, count))\n\n @classmethod\n def repeat_with(cls, function: Nullary[V]) -> AsyncIter[V]:\n return cls.create(async_repeat_with(function))\n\n @classmethod\n def repeat_with_await(cls, function: AsyncNullary[V]) -> AsyncIter[V]:\n return cls.create(async_repeat_with_await(function))\n\n @classmethod\n def repeat_exactly_with(cls, function: Nullary[V], count: int) -> AsyncIter[V]:\n return cls.create(async_repeat_with(function, count))\n\n @classmethod\n def repeat_exactly_with_await(cls, function: AsyncNullary[V], count: int) -> AsyncIter[V]:\n return cls.create(async_repeat_with_await(function, count))\n\n @classmethod\n def count_from_by(cls, start: int, step: int) -> AsyncIter[int]:\n return cls.create(async_count(start, step))\n\n @classmethod\n def count_from(cls, start: int) -> AsyncIter[int]:\n return cls.count_from_by(start, DEFAULT_STEP)\n\n @classmethod\n def count_by(cls, step: int) -> AsyncIter[int]:\n return cls.count_from_by(DEFAULT_START, step)\n\n @classmethod\n def count(cls) -> AsyncIter[int]:\n return cls.count_from_by(DEFAULT_START, DEFAULT_STEP)\n\n @classmethod\n def iterate(cls, function: Unary[V, V], value: V) -> AsyncIter[V]:\n return cls.create(async_iterate(function, value))\n\n @classmethod\n def iterate_exactly(cls, function: Unary[V, V], value: V, count: int) -> AsyncIter[V]:\n return cls.create(async_iterate(function, value, count))\n\n @classmethod\n def iterate_await(cls, function: AsyncUnary[V, V], value: V) -> AsyncIter[V]:\n return cls.create(async_iterate_await(function, value))\n\n @classmethod\n def iterate_exactly_await(\n cls, function: AsyncUnary[V, V], value: V, count: int\n ) -> AsyncIter[V]:\n return cls.create(async_iterate_await(function, value, count))\n\n @classmethod\n def iter_except(cls, function: Nullary[T], *errors: AnyErrorType) -> AsyncIter[T]:\n return cls.create(async_iter_except(function, *errors))\n\n @classmethod\n def iter_except_await(cls, function: AsyncNullary[T], *errors: AnyErrorType) -> AsyncIter[T]:\n return cls.create(async_iter_except_await(function, *errors))\n\n @classmethod\n def iter_with(cls, context_manager: ContextManager[AnyIterable[T]]) -> AsyncIter[T]:\n return cls.create(async_iter_with(context_manager))\n\n @classmethod\n def iter_async_with(\n cls, async_context_manager: AsyncContextManager[AnyIterable[T]]\n ) -> AsyncIter[T]:\n return cls.create(async_iter_async_with(async_context_manager))\n\n @classmethod\n def create_chain(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_chain(*iterables))\n\n @classmethod\n def create_chain_with(cls, iterable: AnyIterable[AnyIterable[T]]) -> AsyncIter[T]:\n return cls.create(async_chain_from_iterable(iterable))\n\n @classmethod\n def create_combine(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_combine(*iterables))\n\n @classmethod\n def create_interleave(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_interleave(*iterables))\n\n @classmethod\n def create_interleave_longest(cls, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return cls.create(async_interleave_longest(*iterables))\n\n @overload\n @classmethod\n def create_zip(cls) -> AsyncIter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip(cls, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return cls.create(async_zip(*iterables))\n\n @overload\n @classmethod\n def create_zip_equal(cls) -> AsyncIter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_equal(cls, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return cls.create(async_zip_equal(*iterables))\n\n @overload\n @classmethod\n def create_zip_longest(cls) -> AsyncIter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[Option[A]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[Option[A], Option[B]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E], Option[F]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[\n Tuple[\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n ]\n ]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[\n Tuple[\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_longest(\n cls, *iterables: AnyIterable[Any]\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n return cls.create(async_zip_longest(*iterables))\n\n @overload\n @classmethod\n def create_cartesian_product(cls) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(cls, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product( # type: ignore\n cls,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_cartesian_product(cls, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return cls.create(async_cartesian_product(*iterables))\n\n @classmethod\n def reversed(cls, reversible: Reversible[T]) -> AsyncIter[T]:\n return cls.create(async_reversed(reversible))\n\n @classmethod\n def function(cls, function: Nullary[T], sentinel: V) -> AsyncIter[T]:\n return cls.create(async_iter_function(function, sentinel))\n\n @classmethod\n def function_await(cls, function: AsyncNullary[T], sentinel: V) -> AsyncIter[T]:\n return cls.create(async_iter_function_await(function, sentinel))\n\n @classmethod\n def create(cls, iterable: AnyIterable[U]) -> AsyncIter[U]:\n return cls(iterable) # type: ignore\n\n @classmethod\n def create_tuple(cls, iterables: DynamicTuple[AnyIterable[U]]) -> DynamicTuple[AsyncIter[U]]:\n return tuple(map(cls, iterables)) # type: ignore\n\n @classmethod\n def create_nested(cls, nested: AnyIterable[AnyIterable[U]]) -> AsyncIter[AsyncIter[U]]:\n return cls(map(cls, nested)) # type: ignore\n\n def __aiter__(self) -> AsyncIter[T]:\n return self\n\n async def __anext__(self) -> T:\n return await async_next_unchecked(self.iterator)\n\n def __await__(self) -> Generator[None, None, List[T]]:\n return self.list().__await__()\n\n def unwrap(self) -> AsyncIterator[T]:\n return self.iterator\n\n def async_iter(self) -> AsyncIter[T]:\n return self\n\n @wrap_future_option\n async def next(self) -> Option[T]:\n return wrap_marked(await async_next_unchecked(self.iterator, marker))\n\n @wrap_future\n async def compare(self: AsyncIter[ST], other: AnyIterable[ST]) -> Ordering:\n return await async_compare(self.iterator, other)\n\n @wrap_future\n async def compare_by(self, other: AnyIterable[T], key: Unary[T, ST]) -> Ordering:\n return await async_compare(self.iterator, other, key)\n\n @wrap_future\n async def compare_by_await(self, other: AnyIterable[T], key: AsyncUnary[T, ST]) -> Ordering:\n return await async_compare_await(self.iterator, other, key)\n\n @wrap_future\n async def length(self) -> int:\n return await async_iter_length(self.iterator)\n\n @wrap_future_option\n async def first(self) -> Option[T]:\n return wrap_marked(await async_first(self.iterator, marker))\n\n @wrap_future_option\n async def last(self) -> Option[T]:\n return wrap_marked(await async_last(self.iterator, marker))\n\n @wrap_future_option\n async def last_with_tail(self) -> Option[T]:\n return wrap_marked(await async_last_with_tail(self.iterator, marker))\n\n def collect(self, function: Unary[AsyncIterable[T], U]) -> U:\n return function(self.iterator)\n\n @wrap_future\n async def collect_await(self, function: AsyncUnary[AsyncIterable[T], U]) -> U:\n return await function(self.iterator)\n\n def collect_iter(self, function: Unary[AsyncIterable[T], AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(self.collect(function))\n\n @wrap_future\n async def list(self) -> List[T]:\n return await async_list(self.iterator)\n\n @wrap_future\n async def set(self: AsyncIter[Q]) -> Set[Q]:\n return await async_set(self.iterator)\n\n @wrap_future\n async def ordered_set(self: AsyncIter[Q]) -> OrderedSet[Q]:\n return await async_ordered_set(self.iterator)\n\n @wrap_future\n async def tuple(self) -> DynamicTuple[T]:\n return await async_tuple(self.iterator)\n\n @wrap_future\n async def dict(self: AsyncIter[Tuple[Q, V]]) -> Dict[Q, V]:\n return await async_dict(self.iterator)\n\n @wrap_future\n async def extract(self) -> Iterator[T]:\n return await async_extract(self.iterator)\n\n @wrap_future\n async def join(self: AsyncIter[AnyStr], string: AnyStr) -> AnyStr:\n return string.join(await self.list())\n\n @wrap_future\n async def string(self: AsyncIter[str]) -> str:\n return await self.join(EMPTY_STRING)\n\n @wrap_future\n async def bytes(self: AsyncIter[bytes]) -> bytes:\n return await self.join(EMPTY_BYTES)\n\n @wrap_future\n async def count_dict(self: AsyncIter[Q]) -> Counter[Q]:\n return await async_count_dict(self.iterator)\n\n @wrap_future\n async def count_dict_by(self, key: Unary[T, Q]) -> Counter[Q]:\n return await async_count_dict(self.iterator, key)\n\n @wrap_future\n async def count_dict_by_await(self, key: AsyncUnary[T, Q]) -> Counter[Q]:\n return await async_count_dict_await(self.iterator, key)\n\n @wrap_future\n async def group_dict(self: AsyncIter[Q]) -> Dict[Q, List[Q]]:\n return await async_group_dict(self.iterator)\n\n @wrap_future\n async def group_dict_by(self, key: Unary[T, Q]) -> Dict[Q, List[T]]:\n return await async_group_dict(self.iterator, key)\n\n @wrap_future\n async def group_dict_by_await(self, key: AsyncUnary[T, Q]) -> Dict[Q, List[T]]:\n return await async_group_dict_await(self.iterator, key)\n\n def group(self) -> AsyncIter[Tuple[T, AsyncIter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n async for group_key, group_iterator in async_group(self.iterator)\n )\n\n def group_by(self, key: Unary[T, U]) -> AsyncIter[Tuple[U, AsyncIter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n async for group_key, group_iterator in async_group(self.iterator, key)\n )\n\n def group_by_await(self, key: AsyncUnary[T, U]) -> AsyncIter[Tuple[U, AsyncIter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n async for group_key, group_iterator in async_group_await(self.iterator, key)\n )\n\n def group_list(self) -> AsyncIter[Tuple[T, List[T]]]:\n return self.create(async_group_list(self.iterator))\n\n def group_list_by(self, key: Unary[T, U]) -> AsyncIter[Tuple[U, List[T]]]:\n return self.create(async_group_list(self.iterator, key))\n\n def group_list_by_await(self, key: AsyncUnary[T, U]) -> AsyncIter[Tuple[U, List[T]]]:\n return self.create(async_group_list_await(self.iterator, key))\n\n @wrap_future\n async def all(self) -> bool:\n return await async_all(self.iterator)\n\n @wrap_future\n async def all_by(self, predicate: Predicate[T]) -> bool:\n return await self.map(predicate).all()\n\n @wrap_future\n async def all_by_await(self, predicate: AsyncPredicate[T]) -> bool:\n return await self.map_await(predicate).all()\n\n @wrap_future\n async def any(self) -> bool:\n return await async_any(self.iterator)\n\n @wrap_future\n async def any_by(self, predicate: Predicate[T]) -> bool:\n return await self.map(predicate).any()\n\n @wrap_future\n async def any_by_await(self, predicate: AsyncPredicate[T]) -> bool:\n return await self.map_await(predicate).any()\n\n @wrap_future\n async def all_equal(self) -> bool:\n return await async_all_equal(self.iterator)\n\n @wrap_future\n async def all_equal_by(self, key: Unary[T, U]) -> bool:\n return await async_all_equal(self.iterator, key)\n\n @wrap_future\n async def all_equal_by_await(self, key: AsyncUnary[T, U]) -> bool:\n return await async_all_equal_await(self.iterator, key)\n\n @wrap_future\n async def all_unique(self) -> bool:\n return await async_all_unique(self.iterator)\n\n @wrap_future\n async def all_unique_by(self, key: Unary[T, U]) -> bool:\n return await async_all_unique(self.iterator, key)\n\n @wrap_future\n async def all_unique_by_await(self, key: AsyncUnary[T, U]) -> bool:\n return await async_all_unique_await(self.iterator, key)\n\n @wrap_future\n async def all_unique_fast(self: AsyncIter[Q]) -> bool:\n return await async_all_unique_fast(self.iterator)\n\n @wrap_future\n async def all_unique_fast_by(self, key: Unary[T, Q]) -> bool:\n return await async_all_unique_fast(self.iterator, key)\n\n @wrap_future\n async def all_unique_fast_by_await(self, key: AsyncUnary[T, Q]) -> bool:\n return await async_all_unique_fast_await(self.iterator, key)\n\n def remove(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_remove(predicate, self.iterator))\n\n def remove_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_remove_await(predicate, self.iterator))\n\n def remove_duplicates(self) -> AsyncIter[T]:\n return self.create(async_remove_duplicates(self.iterator))\n\n def remove_duplicates_by(self, key: Unary[T, U]) -> AsyncIter[T]:\n return self.create(async_remove_duplicates(self.iterator, key))\n\n def remove_duplicates_by_await(self, key: AsyncUnary[T, U]) -> AsyncIter[T]:\n return self.create(async_remove_duplicates_await(self.iterator, key))\n\n def filter(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_filter(predicate, self.iterator))\n\n def filter_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_filter_await(predicate, self.iterator))\n\n def filter_false(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_filter_false(predicate, self.iterator))\n\n def filter_false_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_filter_false_await(predicate, self.iterator))\n\n def filter_except(self, validate: Validate[T], *errors: AnyErrorType) -> AsyncIter[T]:\n return self.create(async_filter_except(validate, self.iterator, *errors))\n\n def filter_except_await(\n self, validate: AsyncValidate[T], *errors: AnyErrorType\n ) -> AsyncIter[T]:\n return self.create(async_filter_except_await(validate, self.iterator, *errors))\n\n def compress(self, selectors: AnySelectors) -> AsyncIter[T]:\n return self.create(async_compress(self.iterator, selectors))\n\n def position_all(self, predicate: Optional[Predicate[T]]) -> AsyncIter[int]:\n return self.create(async_position_all(predicate, self.iterator))\n\n def position_all_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[int]:\n return self.create(async_position_all_await(predicate, self.iterator))\n\n @wrap_future_option\n async def position(self, predicate: Optional[Predicate[T]]) -> Option[int]:\n return wrap_marked(await async_position(predicate, self.iterator, marker))\n\n @wrap_future_option\n async def position_await(self, predicate: AsyncPredicate[T]) -> Option[int]:\n return wrap_marked(await async_position_await(predicate, self.iterator, marker))\n\n def find_all(self, predicate: Optional[Predicate[T]]) -> AsyncIter[T]:\n return self.create(async_find_all(predicate, self.iterator))\n\n def find_all_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_find_all_await(predicate, self.iterator))\n\n @wrap_future_option\n async def find(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(await async_find(predicate, self.iterator, marker)) # type: ignore\n\n @wrap_future_option\n async def find_await(self, predicate: AsyncPredicate[T]) -> Option[T]:\n return wrap_marked(await async_find_await(predicate, self.iterator, marker)) # type: ignore\n\n @wrap_future_option\n async def find_or_first(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(\n await async_find_or_first(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future_option\n async def find_or_first_await(self, predicate: AsyncPredicate[T]) -> Option[T]:\n return wrap_marked(\n await async_find_or_first_await(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future_option\n async def find_or_last(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(\n await async_find_or_last(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future_option\n async def find_or_last_await(self, predicate: AsyncPredicate[T]) -> Option[T]:\n return wrap_marked(\n await async_find_or_last_await(predicate, self.iterator, marker) # type: ignore\n )\n\n @wrap_future\n async def contains(self, item: V) -> bool:\n return await async_contains(item, self.iterator)\n\n @wrap_future\n async def contains_identity(self: AsyncIter[V], item: V) -> bool:\n return await async_contains_identity(item, self.iterator)\n\n @wrap_future_option\n async def reduce(self, function: Binary[T, T, T]) -> Option[T]:\n return wrap_marked(\n await async_reduce(function, self.iterator, marker) # type: ignore # weird\n )\n\n @wrap_future_option\n async def reduce_await(self, function: AsyncBinary[T, T, T]) -> Option[T]:\n return wrap_marked(\n await async_reduce_await(function, self.iterator, marker) # type: ignore # weird\n )\n\n @wrap_future\n async def fold(self, initial: V, function: Binary[V, T, V]) -> V:\n return await async_fold(initial, function, self.iterator)\n\n @wrap_future\n async def fold_await(self, initial: V, function: AsyncBinary[V, T, V]) -> V:\n return await async_fold_await(initial, function, self.iterator)\n\n @wrap_future\n async def sum(self: AsyncIter[S]) -> S:\n return await async_sum(self.iterator)\n\n @wrap_future\n async def sum_with(self: AsyncIter[S], initial: S) -> S:\n return await async_sum(self.iterator, initial)\n\n @wrap_future\n async def product(self: AsyncIter[P]) -> P:\n return await async_product(self.iterator)\n\n @wrap_future\n async def product_with(self: AsyncIter[P], initial: P) -> P:\n return await async_product(self.iterator, initial)\n\n def accumulate_reduce(self, function: Binary[T, T, T]) -> AsyncIter[T]:\n return self.create(async_accumulate_reduce(function, self.iterator))\n\n def accumulate_reduce_await(self, function: AsyncBinary[T, T, T]) -> AsyncIter[T]:\n return self.create(async_accumulate_reduce_await(function, self.iterator))\n\n def accumulate_fold(self, initial: V, function: Binary[V, T, V]) -> AsyncIter[V]:\n return self.create(async_accumulate_fold(initial, function, self.iterator))\n\n def accumulate_fold_await(self, initial: V, function: AsyncBinary[V, T, V]) -> AsyncIter[V]:\n return self.create(async_accumulate_fold_await(initial, function, self.iterator))\n\n def accumulate_sum(self: AsyncIter[S]) -> AsyncIter[S]:\n return self.create(async_accumulate_sum(self.iterator))\n\n def accumulate_sum_with(self: AsyncIter[S], initial: S) -> AsyncIter[S]:\n return self.create(async_accumulate_sum(self.iterator, initial))\n\n def accumulate_product(self: AsyncIter[P]) -> AsyncIter[P]:\n return self.create(async_accumulate_product(self.iterator))\n\n def accumulate_product_with(self: AsyncIter[P], initial: P) -> AsyncIter[P]:\n return self.create(async_accumulate_product(self.iterator, initial))\n\n @wrap_future_option\n async def min(self: AsyncIter[ST]) -> Option[ST]:\n return wrap_marked(await async_min(self.iterator, default=marker))\n\n @wrap_future_option\n async def min_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(await async_min(self.iterator, key=key, default=marker)) # type: ignore\n\n @wrap_future_option\n async def min_by_await(self, key: AsyncUnary[T, ST]) -> Option[T]:\n return wrap_marked(\n await async_min_await(self.iterator, key=key, default=marker) # type: ignore\n )\n\n @wrap_future_option\n async def max(self: AsyncIter[ST]) -> Option[ST]:\n return wrap_marked(await async_max(self.iterator, default=marker))\n\n @wrap_future_option\n async def max_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(await async_max(self.iterator, key=key, default=marker)) # type: ignore\n\n @wrap_future_option\n async def max_by_await(self, key: AsyncUnary[T, ST]) -> Option[T]:\n return wrap_marked(\n await async_max_await(self.iterator, key=key, default=marker) # type: ignore\n )\n\n @wrap_future_option\n async def min_max(self: AsyncIter[ST]) -> Option[Pair[ST]]:\n return wrap_marked(await async_min_max(self.iterator, default=marker))\n\n @wrap_future_option\n async def min_max_by(self, key: Unary[T, ST]) -> Option[Pair[T]]:\n return wrap_marked(await async_min_max(self.iterator, key=key, default=marker))\n\n @wrap_future_option\n async def min_max_by_await(self, key: AsyncUnary[T, ST]) -> Option[Pair[T]]:\n return wrap_marked(await async_min_max_await(self.iterator, key=key, default=marker))\n\n def map(self, function: Unary[T, U]) -> AsyncIter[U]:\n return self.create(async_map(function, self.iterator))\n\n def map_await(self, function: AsyncUnary[T, U]) -> AsyncIter[U]:\n return self.create(async_map_await(function, self.iterator))\n\n def map_except(self, function: Unary[T, U], *errors: AnyErrorType) -> AsyncIter[U]:\n return self.create(async_map_except(function, self.iterator, *errors))\n\n def map_except_await(self, function: AsyncUnary[T, U], *errors: AnyErrorType) -> AsyncIter[U]:\n return self.create(async_map_except_await(function, self.iterator, *errors))\n\n def map_concurrent(self, function: AsyncUnary[T, U]) -> AsyncIter[U]:\n return self.create(async_map_concurrent(function, self.iterator))\n\n def map_concurrent_bound(self, bound: int, function: AsyncUnary[T, U]) -> AsyncIter[U]:\n return self.create(async_map_concurrent_bound(bound, function, self.iterator))\n\n def flat_map(self, function: Unary[T, AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_flat_map(function, self.iterator))\n\n def flat_map_await(self, function: AsyncUnary[T, AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_flat_map_await(function, self.iterator))\n\n def filter_map(self, predicate: Optional[Predicate[T]], function: Unary[T, U]) -> AsyncIter[U]:\n return self.create(async_filter_map(predicate, function, self.iterator))\n\n def filter_await_map(self, predicate: AsyncPredicate[T], function: Unary[T, U]) -> AsyncIter[U]:\n return self.create(async_filter_await_map(predicate, function, self.iterator))\n\n def filter_map_await(\n self, predicate: Optional[Predicate[T]], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_map_await(predicate, function, self.iterator))\n\n def filter_await_map_await(\n self, predicate: AsyncPredicate[T], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_await_map_await(predicate, function, self.iterator))\n\n def filter_false_map(\n self, predicate: Optional[Predicate[T]], function: Unary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_map(predicate, function, self.iterator))\n\n def filter_false_await_map(\n self, predicate: AsyncPredicate[T], function: Unary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_await_map(predicate, function, self.iterator))\n\n def filter_false_map_await(\n self, predicate: Optional[Predicate[T]], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_map_await(predicate, function, self.iterator))\n\n def filter_false_await_map_await(\n self, predicate: AsyncPredicate[T], function: AsyncUnary[T, U]\n ) -> AsyncIter[U]:\n return self.create(async_filter_false_await_map_await(predicate, function, self.iterator))\n\n def flatten(self: AsyncIter[AnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_flatten(self.iterator))\n\n def collapse(self: AsyncIter[RecursiveAnyIterable[U]]) -> AsyncIter[U]:\n return self.create(async_collapse(self.iterator))\n\n def enumerate(self) -> AsyncIter[Tuple[int, T]]:\n return self.create(async_enumerate(self.iterator))\n\n def enumerate_from(self, start: int) -> AsyncIter[Tuple[int, T]]:\n return self.create(async_enumerate(self.iterator, start))\n\n @wrap_future\n async def consume(self) -> None:\n await async_consume(self.iterator)\n\n @wrap_future\n async def for_each(self, function: ForEach[T]) -> None:\n await async_for_each(function, self.iterator)\n\n @wrap_future\n async def for_each_await(self, function: AsyncForEach[T]) -> None:\n await async_for_each_await(function, self.iterator)\n\n def append(self: AsyncIter[V], item: V) -> AsyncIter[V]:\n return self.create(async_append(item, self.iterator))\n\n def prepend(self: AsyncIter[V], item: V) -> AsyncIter[V]:\n return self.create(async_prepend(item, self.iterator))\n\n @wrap_future_option\n async def at(self, index: int) -> Option[T]:\n return wrap_marked(await async_at(index, self.iterator, marker))\n\n @wrap_future_option\n async def at_or_last(self, index: int) -> Option[T]:\n return wrap_marked(await async_at_or_last(index, self.iterator, marker))\n\n @overload\n def slice(self, __stop: Optional[int]) -> AsyncIter[T]:\n ...\n\n @overload\n def slice(\n self, __start: Optional[int], __stop: Optional[int], __step: Optional[int] = ...\n ) -> AsyncIter[T]:\n ...\n\n def slice(self, *slice_args: Optional[int]) -> AsyncIter[T]:\n return self.create(async_iter_slice(self.iterator, *slice_args))\n\n def drop(self, size: int) -> AsyncIter[T]:\n return self.create(async_drop(size, self.iterator))\n\n skip = drop\n\n def rest(self) -> AsyncIter[T]:\n return self.create(async_rest(self.iterator))\n\n def drop_while(self, predicate: Predicate[T]) -> AsyncIter[T]:\n return self.create(async_drop_while(predicate, self.iterator))\n\n skip_while = drop_while\n\n def drop_while_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_drop_while_await(predicate, self.iterator))\n\n skip_while_await = drop_while_await\n\n def take(self, size: int) -> AsyncIter[T]:\n return self.create(async_take(size, self.iterator))\n\n def take_while(self, predicate: Predicate[T]) -> AsyncIter[T]:\n return self.create(async_take_while(predicate, self.iterator))\n\n def take_while_await(self, predicate: AsyncPredicate[T]) -> AsyncIter[T]:\n return self.create(async_take_while_await(predicate, self.iterator))\n\n def step_by(self, step: int) -> AsyncIter[T]:\n return self.create(async_step_by(step, self.iterator))\n\n def tail(self, size: int) -> AsyncIter[T]:\n return self.create(async_tail(size, self.iterator))\n\n def apply_chain(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_chain(self.iterator, *iterables))\n\n chain = mixed_method(create_chain, apply_chain)\n\n def apply_chain_with(self, iterables: AnyIterable[AnyIterable[T]]) -> AsyncIter[T]:\n return self.chain(async_chain_from_iterable(iterables))\n\n chain_with = mixed_method(create_chain_with, apply_chain_with)\n\n def cycle(self) -> AsyncIter[T]:\n return self.create(async_cycle(self.iterator))\n\n def intersperse(self: AsyncIter[V], value: V) -> AsyncIter[V]:\n return self.create(async_intersperse(value, self.iterator))\n\n def intersperse_with(self, function: Nullary[T]) -> AsyncIter[T]:\n return self.create(async_intersperse_with(function, self.iterator))\n\n def intersperse_with_await(self, function: AsyncNullary[T]) -> AsyncIter[T]:\n return self.create(async_intersperse_with_await(function, self.iterator))\n\n def apply_interleave(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_interleave(self.iterator, *iterables))\n\n interleave = mixed_method(create_interleave, apply_interleave)\n\n def apply_interleave_longest(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_interleave_longest(self.iterator, *iterables))\n\n interleave_longest = mixed_method(create_interleave_longest, apply_interleave_longest)\n\n def apply_combine(self, *iterables: AnyIterable[T]) -> AsyncIter[T]:\n return self.create(async_combine(*iterables))\n\n combine = mixed_method(create_combine, apply_combine)\n\n @overload\n def distribute_unsafe(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[1]) -> Tuple1[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[2]) -> Tuple2[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[3]) -> Tuple3[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[4]) -> Tuple4[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[5]) -> Tuple5[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[6]) -> Tuple6[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[7]) -> Tuple7[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[8]) -> Tuple8[AsyncIter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n ...\n\n def distribute_unsafe(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n return self.create_tuple(async_distribute_unsafe(count, self.iterator))\n\n distribute_infinite = distribute_unsafe\n\n @overload\n def distribute(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute(self, count: Literal[1]) -> Tuple1[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[2]) -> Tuple2[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[3]) -> Tuple3[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[4]) -> Tuple4[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[5]) -> Tuple5[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[6]) -> Tuple6[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[7]) -> Tuple7[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[8]) -> Tuple8[AsyncIter[T]]:\n ...\n\n @overload\n def distribute(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n ...\n\n def distribute(self, count: int) -> DynamicTuple[AsyncIter[T]]:\n return self.create_tuple(async_distribute(count, self.iterator))\n\n def divide(self, count: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_divide(count, self.iterator))\n\n def pad(self, value: V) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad(value, self.iterator))\n\n def pad_exactly(self, value: V, size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad(value, self.iterator, size))\n\n def pad_multiple(self, value: V, size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad(value, self.iterator, size, multiple=True))\n\n def pad_none(self) -> AsyncIter[Optional[T]]:\n return self.pad(None)\n\n def pad_none_exactly(self, size: int) -> AsyncIter[Optional[T]]:\n return self.pad_exactly(None, size)\n\n def pad_none_multiple(self, size: int) -> AsyncIter[Optional[T]]:\n return self.pad_multiple(None, size)\n\n def pad_with(self, function: Unary[int, V]) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with(function, self.iterator))\n\n def pad_exactly_with(self, function: Unary[int, V], size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with(function, self.iterator, size))\n\n def pad_multiple_with(self, function: Unary[int, V], size: int) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with(function, self.iterator, size, multiple=True))\n\n def pad_with_await(self, function: AsyncUnary[int, V]) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with_await(function, self.iterator))\n\n def pad_exactly_with_await(\n self, function: AsyncUnary[int, V], size: int\n ) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with_await(function, self.iterator, size))\n\n def pad_multiple_with_await(\n self, function: AsyncUnary[int, V], size: int\n ) -> AsyncIter[Union[T, V]]:\n return self.create(async_pad_with_await(function, self.iterator, size, multiple=True))\n\n def chunks(self, size: int) -> AsyncIter[List[T]]:\n return self.create(async_chunks(size, self.iterator))\n\n def iter_chunks(self, size: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_iter_chunks(size, self.iterator))\n\n def iter_chunks_unsafe(self, size: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_iter_chunks_unsafe(size, self.iterator))\n\n iter_chunks_infinite = iter_chunks_unsafe\n\n @overload\n def groups(self, size: Literal[0]) -> AsyncIter[Never]:\n ...\n\n @overload\n def groups(self, size: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def groups(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def groups(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_groups(size, self.iterator))\n\n @overload\n def groups_longest(self, size: Literal[0]) -> AsyncIter[Never]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[1]) -> AsyncIter[Tuple1[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[2]) -> AsyncIter[Tuple2[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[3]) -> AsyncIter[Tuple3[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[4]) -> AsyncIter[Tuple4[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[5]) -> AsyncIter[Tuple5[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[6]) -> AsyncIter[Tuple6[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[7]) -> AsyncIter[Tuple7[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[8]) -> AsyncIter[Tuple8[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: int) -> AsyncIter[DynamicTuple[Option[T]]]:\n ...\n\n def groups_longest(self, size: int) -> AsyncIter[DynamicTuple[Option[T]]]:\n return self.create(async_groups_longest(size, self.iterator))\n\n def pairs(self) -> AsyncIter[Pair[T]]:\n return self.create(async_pairs(self.iterator))\n\n def pairs_longest(self) -> AsyncIter[Pair[Option[T]]]:\n return self.create(async_pairs_longest(self.iterator))\n\n def iter_windows(self, size: int) -> AsyncIter[AsyncIter[T]]:\n return self.create_nested(async_iter_windows(size, self.iterator))\n\n def list_windows(self, size: int) -> AsyncIter[List[T]]:\n return self.create(async_list_windows(size, self.iterator))\n\n def pairs_windows(self) -> AsyncIter[Pair[T]]:\n return self.create(async_pairs_windows(self.iterator))\n\n @overload\n def tuple_windows(self, size: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def tuple_windows(self, size: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_tuple_windows(size, self.iterator))\n\n def set_windows(self: AsyncIter[Q], size: int) -> AsyncIter[Set[Q]]:\n return self.create(async_set_windows(size, self.iterator))\n\n @overload\n def apply_zip(self) -> AsyncIter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip(self, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n def apply_zip(self, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return self.create(async_zip(self.iterator, *iterables))\n\n zip = mixed_method(create_zip, apply_zip)\n\n @overload\n def apply_zip_equal(self) -> AsyncIter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip_equal(self, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip_equal(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip_equal( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n def apply_zip_equal(self, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return self.create(async_zip_equal(self.iterator, *iterables))\n\n zip_equal = mixed_method(create_zip_equal, apply_zip_equal)\n\n @overload\n def apply_zip_longest(self) -> AsyncIter[Tuple[Option[T]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: AnyIterable[A]\n ) -> AsyncIter[Tuple[Option[T], Option[A]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n ...\n\n def apply_zip_longest(\n self, *iterables: AnyIterable[Any]\n ) -> AsyncIter[DynamicTuple[Option[Any]]]:\n return self.create(async_zip_longest(self.iterator, *iterables))\n\n zip_longest = mixed_method(create_zip_longest, apply_zip_longest)\n\n def transpose(self: AsyncIter[AnyIterable[T]]) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_transpose(self.iterator))\n\n @overload\n def apply_cartesian_product(self) -> AsyncIter[Tuple[T]]:\n ...\n\n @overload\n def apply_cartesian_product(self, __iterable_a: AnyIterable[A]) -> AsyncIter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self, __iterable_a: AnyIterable[A], __iterable_b: AnyIterable[B]\n ) -> AsyncIter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n ) -> AsyncIter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n ) -> AsyncIter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: AnyIterable[A],\n __iterable_b: AnyIterable[B],\n __iterable_c: AnyIterable[C],\n __iterable_d: AnyIterable[D],\n __iterable_e: AnyIterable[E],\n __iterable_f: AnyIterable[F],\n __iterable_g: AnyIterable[G],\n __iterable_h: AnyIterable[H],\n ) -> AsyncIter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_cartesian_product( # type: ignore\n self,\n __iterable_a: AnyIterable[Any],\n __iterable_b: AnyIterable[Any],\n __iterable_c: AnyIterable[Any],\n __iterable_d: AnyIterable[Any],\n __iterable_e: AnyIterable[Any],\n __iterable_f: AnyIterable[Any],\n __iterable_g: AnyIterable[Any],\n __iterable_h: AnyIterable[Any],\n __iterable_n: AnyIterable[Any],\n *iterables: AnyIterable[Any],\n ) -> AsyncIter[DynamicTuple[Any]]:\n ...\n\n def apply_cartesian_product(self, *iterables: AnyIterable[Any]) -> AsyncIter[DynamicTuple[Any]]:\n return self.create(async_cartesian_product(self.iterator, *iterables))\n\n cartesian_product = mixed_method(create_cartesian_product, apply_cartesian_product)\n\n @overload\n def cartesian_power(self, power: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n def cartesian_power(self, power: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_cartesian_power(power, self.iterator))\n\n @overload\n def combinations(self, count: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def combinations(self, count: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def combinations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def combinations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_combinations(count, self.iterator))\n\n @overload\n def combinations_with_replacement(self, count: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def combinations_with_replacement(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_combinations_with_replacement(count, self.iterator))\n\n def permute(self) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_permute(self.iterator))\n\n @overload\n def permutations(self, count: Literal[0]) -> AsyncIter[EmptyTuple]:\n ...\n\n @overload\n def permutations(self, count: Literal[1]) -> AsyncIter[Tuple1[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[2]) -> AsyncIter[Tuple2[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[3]) -> AsyncIter[Tuple3[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[4]) -> AsyncIter[Tuple4[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[5]) -> AsyncIter[Tuple5[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[6]) -> AsyncIter[Tuple6[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[7]) -> AsyncIter[Tuple7[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[8]) -> AsyncIter[Tuple8[T]]:\n ...\n\n @overload\n def permutations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n ...\n\n def permutations(self, count: int) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_permutations(count, self.iterator))\n\n def power_set(self) -> AsyncIter[DynamicTuple[T]]:\n return self.create(async_power_set(self.iterator))\n\n def reverse(self) -> AsyncIter[T]:\n return self.create(async_reverse(self.iterator))\n\n @wrap_future\n async def sorted(self: AsyncIter[ST]) -> List[ST]:\n return await async_sorted(self.iterator)\n\n @wrap_future\n async def sorted_by(self, key: Unary[T, ST]) -> List[T]:\n return await async_sorted(self.iterator, key=key)\n\n @wrap_future\n async def sorted_reverse(self: AsyncIter[ST]) -> List[ST]:\n return await async_sorted(self.iterator, reverse=True)\n\n @wrap_future\n async def sorted_reverse_by(self, key: Unary[T, ST]) -> List[T]:\n return await async_sorted(self.iterator, key=key, reverse=True)\n\n @wrap_future\n async def sorted_by_await(self, key: AsyncUnary[T, ST]) -> List[T]:\n return await async_sorted_await(self.iterator, key=key)\n\n @wrap_future\n async def sorted_reverse_by_await(self, key: AsyncUnary[T, ST]) -> List[T]:\n return await async_sorted_await(self.iterator, key=key, reverse=True)\n\n def sort(self: AsyncIter[ST]) -> AsyncIter[ST]:\n return self.create(async_sort(self.iterator))\n\n def sort_by(self, key: Unary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort(self.iterator, key=key))\n\n def sort_reverse(self: AsyncIter[ST]) -> AsyncIter[ST]:\n return self.create(async_sort(self.iterator, reverse=True))\n\n def sort_reverse_by(self, key: Unary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort(self.iterator, key=key, reverse=True))\n\n def sort_by_await(self, key: AsyncUnary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort_await(self.iterator, key=key))\n\n def sort_reverse_by_await(self, key: AsyncUnary[T, ST]) -> AsyncIter[T]:\n return self.create(async_sort_await(self.iterator, key=key, reverse=True))\n\n @wrap_future\n async def is_sorted(self: AsyncIter[LT]) -> bool:\n return await async_is_sorted(self.iterator)\n\n @wrap_future\n async def is_sorted_by(self, key: Unary[T, LT]) -> bool:\n return await async_is_sorted(self.iterator, key)\n\n @wrap_future\n async def is_sorted_reverse(self: AsyncIter[LT]) -> bool:\n return await async_is_sorted(self.iterator, reverse=True)\n\n @wrap_future\n async def is_sorted_reverse_by(self, key: Unary[T, LT]) -> bool:\n return await async_is_sorted(self.iterator, key, reverse=True)\n\n @wrap_future\n async def is_sorted_strict(self: AsyncIter[ST]) -> bool:\n return await async_is_sorted(self.iterator, strict=True)\n\n @wrap_future\n async def is_sorted_strict_by(self, key: Unary[T, ST]) -> bool:\n return await async_is_sorted(self.iterator, key, strict=True)\n\n @wrap_future\n async def is_sorted_reverse_strict(self: AsyncIter[ST]) -> bool:\n return await async_is_sorted(self.iterator, strict=True, reverse=True)\n\n @wrap_future\n async def is_sorted_reverse_strict_by(self, key: Unary[T, ST]) -> bool:\n return await async_is_sorted(self.iterator, key, strict=True, reverse=True)\n\n @wrap_future\n async def is_sorted_by_await(self, key: AsyncUnary[T, LT]) -> bool:\n return await async_is_sorted_await(self.iterator, key)\n\n @wrap_future\n async def is_sorted_reverse_by_await(self, key: AsyncUnary[T, LT]) -> bool:\n return await async_is_sorted_await(self.iterator, key, reverse=True)\n\n @wrap_future\n async def is_sorted_strict_by_await(self, key: AsyncUnary[T, ST]) -> bool:\n return await async_is_sorted_await(self.iterator, key, strict=True)\n\n @wrap_future\n async def is_sorted_reverse_strict_by_await(self, key: AsyncUnary[T, ST]) -> bool:\n return await async_is_sorted_await(self.iterator, key, strict=True, reverse=True)\n\n def duplicates_fast(self: AsyncIter[Q]) -> AsyncIter[Q]:\n return self.create(async_duplicates_fast(self.iterator))\n\n def duplicates_fast_by(self, key: Unary[T, Q]) -> AsyncIter[T]:\n return self.create(async_duplicates_fast(self.iterator, key))\n\n def duplicates_fast_by_await(self, key: AsyncUnary[T, Q]) -> AsyncIter[T]:\n return self.create(async_duplicates_fast_await(self.iterator, key))\n\n def duplicates(self) -> AsyncIter[T]:\n return self.create(async_duplicates(self.iterator))\n\n def duplicates_by(self, key: Unary[T, V]) -> AsyncIter[T]:\n return self.create(async_duplicates(self.iterator, key))\n\n def duplicates_by_await(self, key: AsyncUnary[T, V]) -> AsyncIter[T]:\n return self.create(async_duplicates_await(self.iterator, key))\n\n def unique_fast(self: AsyncIter[Q]) -> AsyncIter[Q]:\n return self.create(async_unique_fast(self.iterator))\n\n def unique_fast_by(self, key: Unary[T, Q]) -> AsyncIter[T]:\n return self.create(async_unique_fast(self.iterator, key))\n\n def unique_fast_by_await(self, key: AsyncUnary[T, Q]) -> AsyncIter[T]:\n return self.create(async_unique_fast_await(self.iterator, key))\n\n def unique(self) -> AsyncIter[T]:\n return self.create(async_unique(self.iterator))\n\n def unique_by(self, key: Unary[T, V]) -> AsyncIter[T]:\n return self.create(async_unique(self.iterator, key))\n\n def unique_by_await(self, key: AsyncUnary[T, V]) -> AsyncIter[T]:\n return self.create(async_unique_await(self.iterator, key))\n\n def partition(self, predicate: Optional[Predicate[T]]) -> Pair[AsyncIter[T]]:\n true, false = async_partition(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n def partition_await(self, predicate: AsyncPredicate[T]) -> Pair[AsyncIter[T]]:\n true, false = async_partition_await(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n def partition_unsafe(self, predicate: Optional[Predicate[T]]) -> Pair[AsyncIter[T]]:\n true, false = async_partition_unsafe(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n partition_infinite = partition_unsafe\n\n def partition_unsafe_await(self, predicate: AsyncPredicate[T]) -> Pair[AsyncIter[T]]:\n true, false = async_partition_unsafe_await(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n partition_infinite_await = partition_unsafe_await\n\n def copy(self) -> AsyncIter[T]:\n iterator, result = async_copy(self.iterator)\n\n self._replace(iterator)\n\n return self.create(result)\n\n def copy_unsafe(self) -> AsyncIter[T]:\n iterator, result = async_copy_unsafe(self.iterator)\n\n self._replace(iterator)\n\n return self.create(result)\n\n copy_infinite = copy_unsafe\n\n @wrap_future\n async def spy(self, size: int) -> List[T]:\n result, iterator = await async_spy(size, self.iterator)\n\n self._replace(iterator)\n\n return result\n\n @wrap_future_option\n async def peek(self) -> Option[T]:\n item, iterator = await async_peek(self.iterator, marker)\n\n self._replace(iterator)\n\n return wrap_marked(item)\n\n @wrap_future\n async def has_next(self) -> bool:\n result, iterator = await async_has_next(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n @wrap_future\n async def is_empty(self) -> bool:\n result, iterator = await async_is_empty(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def repeat_last(self) -> AsyncIter[T]:\n return self.create(async_repeat_last(self.iterator))\n\n def repeat_each(self, count: int) -> AsyncIter[T]:\n return self.create(async_repeat_each(count, self.iterator))\n\n def inspect(self, function: Inspect[T]) -> AsyncIter[T]:\n return self.create(async_inspect(function, self.iterator))\n\n def inspect_await(self, function: AsyncInspect[T]) -> AsyncIter[T]:\n return self.create(async_inspect_await(function, self.iterator))\n\n def wait(self: AsyncIter[Awaitable[U]]) -> AsyncIter[U]:\n return self.create(async_wait(self.iterator))\n\n def wait_concurrent(self: AsyncIter[Awaitable[U]]) -> AsyncIter[U]:\n return self.create(async_wait_concurrent(self.iterator))\n\n def wait_concurrent_bound(self: AsyncIter[Awaitable[U]], bound: int) -> AsyncIter[U]:\n return self.create(async_wait_concurrent_bound(bound, self.iterator))\n\n @wrap_future\n async def into_iter(self) -> Iter[T]:\n return iter(await self.extract())\n
"},{"location":"reference/async_iters/#iters.async_iters.AsyncIter.iterator","title":"iterator: AsyncIterator[T]
property
","text":"The underlying iterator.
"},{"location":"reference/async_utils/","title":"Async Utilities","text":""},{"location":"reference/iters/","title":"Iterators","text":""},{"location":"reference/iters/#iters.iters.iter","title":"iter = Iter
module-attribute
","text":"An alias of Iter
.
"},{"location":"reference/iters/#iters.iters.reversed","title":"reversed = iter.reversed
module-attribute
","text":"An alias of iter.reversed
.
"},{"location":"reference/iters/#iters.iters.Iter","title":"Iter
","text":" Bases: Iterator[T]
Represents iterators.
Source code in iters/iters.py
class Iter(Iterator[T]):\n \"\"\"Represents iterators.\"\"\"\n\n # internals\n\n _iterator: Iterator[T]\n\n def __init__(self, iterable: Iterable[T]) -> None:\n self._iterator = standard_iter(iterable)\n\n def _replace(self, iterator: Iterator[T]) -> None:\n self._iterator = iterator\n\n # implementation\n\n @property\n def iterator(self) -> Iterator[T]:\n \"\"\"The underlying iterator.\"\"\"\n return self._iterator\n\n @classmethod\n def empty(cls) -> Iter[T]:\n \"\"\"Creates an empty iterator.\n\n Example:\n ```python\n >>> iterator = iter.empty()\n >>> iterator.next()\n Null()\n ```\n\n Returns:\n An empty iterator.\n \"\"\"\n return cls.create(empty())\n\n @classmethod\n def of(cls, *items: V) -> Iter[V]:\n \"\"\"Creates an iterator from `items`.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> iterator.next()\n Some(13)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Some(69)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n *items: The items to iterate over.\n\n Returns:\n An iterator over `items`.\n \"\"\"\n return cls.create(items)\n\n @classmethod\n def once(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that yields the `value` exactly once.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Example:\n ```python\n >>> iterator = iter.once(42)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n value: The value to yield.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value`.\n \"\"\"\n return cls.create(once(value))\n\n @classmethod\n def once_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that lazily generates an item exactly once\n by invoking the `function` provided.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Unlike [`once`][iters.iters.Iter.once], this function will\n lazily generate the item on request.\n\n Example:\n ```python\n >>> iterator = iter.once_with(tuple)\n >>> iterator.next()\n Some(())\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with the generated `value`.\n \"\"\"\n return cls.create(once_with(function))\n\n @classmethod\n def repeat(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly repeats a single `value`.\n\n This function repeats a single value over and over again.\n\n Infinite iterators like [`repeat`][iters.iters.Iter.repeat]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n >>> fours = iter.repeat(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> # ad infinitum...\n ```\n\n Arguments:\n value: The value to repeat.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value`.\n \"\"\"\n return cls.create(repeat(value))\n\n @classmethod\n def repeat_exactly(cls, value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that repeats a single `value` exactly `count` times.\n\n This function is a shorthand for [`iter.repeat(value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n # let's only have four fours\n iterator = iter.repeat_exactly(4, 4)\n\n assert iterator.list() == [4, 4, 4, 4]\n ```\n\n Arguments:\n value: The value to repeat.\n count: The number of times to repeat the `value`.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value` repeated `count` times.\n \"\"\"\n return cls.create(repeat(value, count))\n\n @classmethod\n def repeat_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly generates values.\n\n This function repeats generated values over and over again.\n\n Infinite iterators like [`repeat_with`][iters.iters.Iter.repeat_with]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n iterator = iter.repeat_with(tuple)\n\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n\n # ... ad infinitum\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value` of type `V`.\n \"\"\"\n return cls.create(repeat_with(function))\n\n @classmethod\n def repeat_exactly_with(cls, function: Nullary[V], count: int) -> Iter[V]:\n \"\"\"Creates an iterator that generates values of type `V` exactly `count` times.\n\n This function is a shorthand for\n [`iter.repeat_with(function).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n assert iter.repeat_exactly_with(tuple, 3).tuple() == ((), (), ()) # tuple triple!\n ```\n\n Arguments:\n function: The value-generating function to use.\n count: The number of times to repeat values.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with repeated\n `value` of type `V` exactly `count` times.\n \"\"\"\n return cls.create(repeat_with(function, count))\n\n @classmethod\n def count_from_by(cls, start: int, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `start`.\n\n Example:\n ```python\n iterator = iter.count_from_by(1, 2)\n\n assert iterator.next() == 1\n assert iterator.next() == 3\n assert iterator.next() == 5\n assert iterator.next() == 7\n assert iterator.next() == 9\n ```\n\n Arguments:\n start: The value to start from.\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.create(count(start, step))\n\n @classmethod\n def count_from(cls, start: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `start`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(start, 1)\n ```\n\n Arguments:\n start: The value to start from.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(start, DEFAULT_STEP)\n\n @classmethod\n def count_by(cls, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, step)\n ```\n\n Arguments:\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, step)\n\n @classmethod\n def count(cls) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, 1)\n ```\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, DEFAULT_STEP)\n\n @classmethod\n def iterate(cls, function: Unary[V, V], value: V) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls endlessly, i.e. `value`,\n `function(value)`, `function(function(value))`, ...\n\n Example:\n ```python\n zero = 0\n\n def successor(natural: int) -> int:\n return natural + 1\n\n naturals = iter.iterate(successor, zero)\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value))\n\n @classmethod\n def iterate_exactly(cls, function: Unary[V, V], value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls exactly `count` times.\n\n This is a shorthand for\n [`iter.iterate(function, value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n def wrap(item: T) -> List[T]:\n return [item]\n\n iter.iterate_exactly(wrap, 13, 5).list() == [\n 13, [13], [[13]], [[[13]]], [[[[13]]]]\n ]\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n count: The amount of function iterations.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value, count))\n\n @classmethod\n def iter_except(cls, function: Nullary[T], *errors: AnyErrorType) -> Iter[T]:\n \"\"\"Creates an iterator that repeatedly calls `function` until\n any of the `errors` is encountered.\n\n Example:\n An interesting way to reverse arrays:\n\n ```python\n array = [1, 2, 3]\n\n iter.iter_except(array.pop, IndexError).list() == [3, 2, 1]\n ```\n\n Arguments:\n function: The function to iterate.\n *errors: The errors to `except`, stopping iteration.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function results.\n \"\"\"\n return cls.create(iter_except(function, *errors))\n\n @classmethod\n def iter_with(cls, context_manager: ContextManager[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator over the iterable returned by `context_manager`.\n\n This is essentially equivalent to:\n\n ```python\n def iter_with(context_manager: ContextManager[Iterable[T]]) -> Iterator[T]:\n with context_manager as iterable:\n for item in iterable:\n yield item\n\n iterator = iter(iter_with(context_manager))\n ```\n\n This function can be used to open and close files, for example;\n let us consider parsing some file containing integers on every line.\n\n Example:\n ```python\n array = iter.iter_with(open(\"file.in\")).map(int).list()\n ```\n\n Arguments:\n context_manager: The context manager returning an iterable.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over items in an iterable.\n \"\"\"\n return cls.create(iter_with(context_manager))\n\n @classmethod\n def create_chain(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator chaining `iterables` together.\n\n For example, it can be used to chain arrays.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [7, 8, 9]\n\n assert iter.create_chain(a, b, c).list() == a + b + c\n ```\n\n Arguments:\n *iterables: Iterables to chain together.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain(*iterables))\n\n @classmethod\n def create_chain_with(cls, iterable: Iterable[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator chaining iterables in the `iterable` together.\n\n This function essentially flattens the `iterable` provided.\n\n Example:\n ```python\n matrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9],\n ]\n\n result = 45\n\n assert iter.create_chain_with(matrix).sum() == result\n ```\n\n Arguments:\n iterable: The iterable of iterables to chain.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain_from_iterable(iterable))\n\n @classmethod\n def create_combine(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator combining `iterables`.\n\n This method is a slightly different version of\n [`create_interleave_longest`][iters.iters.Iter.create_interleave_longest].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.combine(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to combine.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over combined iterables.\n \"\"\"\n return cls.create(combine(*iterables))\n\n @classmethod\n def create_interleave(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.create_interleave(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave(*iterables))\n\n @classmethod\n def create_interleave_longest(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n This method is a slightly different version of\n [`create_combine`][iters.iters.Iter.create_combine].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6, 7, 8, 9]\n\n assert iter.create_interleave_longest(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave_longest(*iterables))\n\n @overload\n @classmethod\n def create_zip(cls) -> Iter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip(cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]) -> Iter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4, 5)\n\n y = \"nekit\"\n\n iter.create_zip(x, y).list() == [(1, \"n\"), (2, \"e\"), (3, \"k\"), (4, \"i\"), (5, \"t\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip(*iterables))\n\n @overload\n @classmethod\n def create_zip_equal(cls) -> Iter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_zip_equal( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_equal(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is the strict version of [`create_zip`][iters.iters.Iter.create_zip].\n\n Example:\n ```python\n x = (1, 2, 3)\n\n y = \"dev\"\n\n iter.create_zip_equal(x, y).list() == [(1, \"d\"), (2, \"e\"), (3, \"v\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Raises:\n ValueError: Iterables have different lengths.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_equal(*iterables))\n\n @overload\n @classmethod\n def create_zip_longest(cls) -> Iter[T]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[Option[A]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[Option[A], Option[B]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E], Option[F]]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E], Option[F], Option[G],]]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[\n Tuple[\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n @classmethod\n def create_zip_longest( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Option[Any]]]:\n ...\n\n @no_type_check\n @classmethod\n def create_zip_longest(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is a version of [`create_zip`][iters.iters.Iter.create_zip] that places [`None`][None]\n in place of a *j*-th item of an *i*-th tuple when a *j*-th iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4)\n\n y = \"dev\"\n\n f = \"x\"\n\n def process(a: Option[int], b: Option[str]) -> Tuple[int, str]:\n return (a.unwrap_or(0), b.unwrap_or(f))\n\n assert (\n iter.create_zip_longest(x, y)\n .map(unpack_binary(process))\n .list()\n ) == [(1, \"d\"), (2, \"e\"), (3, \"v\"), (4, \"x\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_longest(*iterables))\n\n @overload\n @classmethod\n def create_cartesian_product(cls) -> Iter[EmptyTuple]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(cls, __iterable_a: Iterable[A]) -> Iter[Tuple[A]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[A, B]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[A, B, C]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[A, B, C, D]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[A, B, C, D, E]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[A, B, C, D, E, F]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[A, B, C, D, E, F, G]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product(\n cls,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n @classmethod\n def create_cartesian_product( # type: ignore\n cls,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n @no_type_check\n @classmethod\n def create_cartesian_product(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Creates an iterator over the\n [*Cartesian product*](https://en.wikipedia.org/wiki/Cartesian_product) of `iterables`.\n\n Warning:\n It only makes sense to compute the product of finite iterables.\n\n Example:\n ```python\n a = (1, 2, 3)\n b = \"xyz\"\n\n c = [\n (1, \"x\"), (1, \"y\"), (1, \"z\"),\n (2, \"x\"), (2, \"y\"), (2, \"z\"),\n (3, \"x\"), (3, \"y\"), (3, \"z\"),\n ]\n\n assert iter.create_cartesian_product(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to compute the Cartesian product of.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over the Cartesian product of iterables.\n \"\"\"\n return cls.create(cartesian_product(*iterables))\n\n @classmethod\n def reversed(cls, reversible: Reversible[T]) -> Iter[T]:\n \"\"\"Creates an iterator over the reversed `reversible`.\n\n Example:\n ```python\n assert iter.reversed([1, 2, 3]).list() == [3, 2, 1]\n ```\n\n Arguments:\n reversible: The reversible to reverse.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over the reversed reversible.\n \"\"\"\n return cls.create(standard_reversed(reversible))\n\n @classmethod\n def function(cls, function: Nullary[T], sentinel: V) -> Iter[T]:\n \"\"\"Creates an iterator over `function` call results until it returns the `sentinel`.\n\n Example:\n ```python\n EMPTY_BYTES = bytes()\n\n READ_BINARY = \"rb\"\n\n CHUNK_SIZE = 65536\n\n def read_chunk(file: BinaryIO) -> Nullary[bytes]:\n def reader(size: int = CHUNK_SIZE) -> bytes:\n return file.read(size)\n\n return reader\n\n with path.open(READ_BINARY) as file:\n iter.function(read_chunk(file), EMPTY_BYTES).for_each(process_chunk)\n ```\n\n Arguments:\n function: The function to iterate.\n sentinel: The sentinel to stop at.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function calls until the `sentinel` is met.\n \"\"\"\n return cls.create(iter_function(function, sentinel))\n\n @classmethod\n def create(cls, iterable: Iterable[U]) -> Iter[U]:\n return cls(iterable) # type: ignore\n\n @classmethod\n def create_tuple(cls, iterables: DynamicTuple[Iterable[U]]) -> DynamicTuple[Iter[U]]:\n return tuple(map(cls, iterables)) # type: ignore\n\n @classmethod\n def create_nested(cls, nested: Iterable[Iterable[U]]) -> Iter[Iter[U]]:\n return cls(map(cls, nested)) # type: ignore\n\n @classmethod\n def create_option(cls, option: Option[Iterable[U]]) -> Option[Iter[U]]:\n return option.map(cls) # type: ignore\n\n def __iter__(self) -> Iter[T]:\n return self\n\n def __next__(self) -> T:\n return next(self.iterator)\n\n def unwrap(self) -> Iterator[T]:\n \"\"\"Unwraps the underlying iterator.\n\n Returns:\n The underlying iterator.\n \"\"\"\n return self.iterator\n\n def iter(self) -> Iter[T]:\n \"\"\"Simply returns `self`.\n\n Returns:\n `self`, the current iterator.\n \"\"\"\n return self\n\n def next(self) -> Option[T]:\n \"\"\"Returns the next item in the iterator.\n\n Example:\n ```python\n value = 42\n\n iterator = iter.once(value)\n\n assert iterator.next().unwrap() is value\n ```\n\n Returns:\n The next item.\n \"\"\"\n return wrap_marked(next(self.iterator, marker))\n\n def compare(self: Iter[ST], other: Iterable[ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable.\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.compare(array).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other)\n\n def compare_by(self, other: Iterable[T], key: Unary[T, ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable using the `key` function.\n\n Example:\n ```python\n array = [13, 34, 42]\n negative = [-x for x in array]\n\n iterator = iter(array)\n\n assert iterator.compare_by(negative, abs).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n key: The key function.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other, key)\n\n def length(self) -> int:\n \"\"\"Computes the length of the iterator.\n\n Example:\n ```python\n assert iter.repeat_exactly(7, 7).length() == 7\n ```\n\n Warning:\n This function exhausts the underlying iterator!\n\n Returns:\n The length of the iterator.\n \"\"\"\n return iter_length(self.iterator)\n\n def first(self) -> Option[T]:\n \"\"\"Returns the first item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.first().unwrap() is value\n ```\n\n Returns:\n The first item.\n \"\"\"\n return wrap_marked(first(self.iterator, marker))\n\n def last(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last(self.iterator, marker))\n\n def last_with_tail(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Note:\n This method uses the [`tail`][iters.utils.tail] function.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last_with_tail().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last_with_tail(self.iterator, marker))\n\n def collect(self, function: Unary[Iterable[T], U]) -> U:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n function(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.collect(list) == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call.\n \"\"\"\n return function(self.iterator)\n\n def collect_iter(self, function: Unary[Iterable[T], Iterable[U]]) -> Iter[U]:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n iterator.create(iterator.collect(function))\n ```\n\n Example:\n ```python\n from typing import TypeVar\n\n T = TypeVar(\"T\")\n\n def identity(item: T) -> T:\n return item\n\n array = [13, 25, 34]\n\n iterator = iter(array).collect_iter(identity)\n\n assert iterator.list() == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call, wrapped back into an iterator.\n \"\"\"\n return self.create(self.collect(function))\n\n def list(self) -> List[T]:\n \"\"\"Collects the iterator into the [`List[T]`][list].\n\n This is equivalent to:\n\n ```python\n list(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.list() == array\n ```\n\n Returns:\n The [`List[T]`][list] over the iterator.\n \"\"\"\n return list(self.iterator)\n\n def set(self: Iter[Q]) -> Set[Q]:\n \"\"\"Collects the iterator into the [`Set[Q]`][set].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n set(iterator.unwrap())\n ```\n\n Example:\n ```python\n set = {13, 42, 69}\n\n iterator = iter(set)\n\n assert iterator.set() == set\n ```\n\n Returns:\n The [`Set[Q]`][set] over the iterator.\n \"\"\"\n return set(self.iterator)\n\n def ordered_set(self: Iter[Q]) -> OrderedSet[Q]:\n \"\"\"Collects the iterator into the [`OrderedSet[Q]`][iters.ordered_set.OrderedSet].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n ordered_set(iterator.unwrap())\n ```\n\n Example:\n ```python\n ordered_set = OrderedSet([13, 42, 69])\n\n iterator = iter(ordered_set)\n\n assert iterator.ordered_set() == ordered_set\n ```\n\n Returns:\n The [`OrderedSet[Q]`][iters.ordered_set.OrderedSet] over the iterator.\n \"\"\"\n return ordered_set(self.iterator)\n\n def tuple(self) -> DynamicTuple[T]:\n \"\"\"Collects the iterator into the [`Tuple[T, ...]`][tuple].\n\n This is equivalent to:\n\n ```python\n tuple(iterator.unwrap())\n ```\n\n Example:\n ```python\n tuple = (-1, 0, 1)\n\n iterator = iter(tuple)\n\n assert iterator.tuple() == tuple\n ```\n\n Returns:\n The [`Tuple[T, ...]`][tuple] over the iterator.\n \"\"\"\n return tuple(self.iterator)\n\n def dict(self: Iter[Tuple[Q, V]]) -> Dict[Q, V]:\n \"\"\"Collects the iterator into the [`Dict[Q, V]`][dict].\n\n Warning:\n The first item in each couple has to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n dict(iterator.unwrap())\n ```\n\n Example:\n ```python\n mapping = {13: \"nekit\", 42: \"dev\"}\n\n iterator = iter(mapping.items())\n\n assert iterator.dict() == mapping\n ```\n\n Returns:\n The [`Dict[Q, V]`][dict] over the iterator.\n \"\"\"\n return dict(self.iterator)\n\n def join(self: Iter[AnyStr], string: AnyStr) -> AnyStr:\n \"\"\"Joins the iterator using the `string`.\n\n Warning:\n The iterator must contain only string items for this method to work.\n\n This is equivalent to:\n\n ```python\n string.join(iterator.unwrap())\n ```\n\n Example:\n ```python\n result = \"melody, nekit\"\n\n string = \", \"\n\n iterator = iter(result.split(string))\n\n assert iterator.join(string) == result\n ```\n\n Returns:\n The joined [`str`][str] or [`bytes`][bytes] depending on the `string` type.\n \"\"\"\n return string.join(self.iterator)\n\n def string(self: Iter[str]) -> str:\n \"\"\"Joins the iterator into the [`str`][str] string.\n\n Warning:\n The iterator must contain only items of type [`str`][str] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_STRING)\n ```\n\n Example:\n ```python\n strings = (\"x\", \"y\", \"z\")\n string = \"xyz\"\n\n iterator = iter(strings)\n\n assert iterator.string() == string\n ```\n\n Returns:\n The joined [`str`][str] string.\n \"\"\"\n return self.join(EMPTY_STRING)\n\n def bytes(self: Iter[bytes]) -> bytes:\n \"\"\"Joins the iterator into the [`bytes`][bytes] string.\n\n Warning:\n The iterator must contain only items of type [`bytes`][bytes] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_BYTES)\n ```\n\n Returns:\n The joined [`bytes`][bytes] string.\n \"\"\"\n return self.join(EMPTY_BYTES)\n\n def count_dict(self: Iter[Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n Example:\n ```python\n bits = (0, 1, 1, 0, 1, 1, 1, 0)\n\n result = [(1, 5), (0, 3)]\n\n iterator = iter(bits)\n\n assert iterator.count_dict().most_common() == result\n ```\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the items of the iterator.\n \"\"\"\n return count_dict(self.iterator)\n\n def count_dict_by(self, key: Unary[T, Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter]\n by applying the `key` function.\n\n Example:\n ```python\n sets = [{}, {0}, {1}, {0, 1}]\n\n iterator = iter(sets)\n\n result = [(1, 2), (2, 1), (0, 1)]\n\n assert iterator.count_dict_by(len).most_common() == result\n ```\n\n Arguments:\n key: The key function.\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the keys\n corresponding to the items of the iterator.\n \"\"\"\n return count_dict(self.iterator, key)\n\n def group_dict(self: Iter[Q]) -> Dict[Q, List[Q]]:\n return group_dict(self.iterator)\n\n def group_dict_by(self, key: Unary[T, Q]) -> Dict[Q, List[T]]:\n return group_dict(self.iterator, key)\n\n def group(self) -> Iter[Tuple[T, Iter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n for group_key, group_iterator in group(self.iterator)\n )\n\n def group_by(self, key: Unary[T, U]) -> Iter[Tuple[U, Iter[T]]]:\n return self.create(\n (group_key, self.create(group_iterator))\n for group_key, group_iterator in group(self.iterator, key)\n )\n\n def group_list(self) -> Iter[Tuple[T, List[T]]]:\n return self.create(group_list(self.iterator))\n\n def group_list_by(self, key: Unary[T, U]) -> Iter[Tuple[U, List[T]]]:\n return self.create(group_list(self.iterator, key))\n\n def all(self) -> bool:\n return all(self.iterator)\n\n def all_by(self, predicate: Predicate[T]) -> bool:\n return self.map(predicate).all()\n\n def any(self) -> bool:\n return any(self.iterator)\n\n def any_by(self, predicate: Predicate[T]) -> bool:\n return self.map(predicate).any()\n\n def all_equal(self) -> bool:\n return all_equal(self.iterator)\n\n def all_equal_by(self, key: Unary[T, U]) -> bool:\n return all_equal(self.iterator, key)\n\n def all_unique(self) -> bool:\n return all_unique(self.iterator)\n\n def all_unique_by(self, key: Unary[T, U]) -> bool:\n return all_unique(self.iterator, key)\n\n def all_unique_fast(self: Iter[Q]) -> bool:\n return all_unique_fast(self.iterator)\n\n def all_unique_fast_by(self, key: Unary[T, Q]) -> bool:\n return all_unique_fast(self.iterator, key)\n\n def remove(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(remove(predicate, self.iterator))\n\n def remove_duplicates(self) -> Iter[T]:\n return self.create(remove_duplicates(self.iterator))\n\n def remove_duplicates_by(self, key: Unary[T, U]) -> Iter[T]:\n return self.create(remove_duplicates(self.iterator, key))\n\n def filter(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(filter(predicate, self.iterator))\n\n def filter_false(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(filter_false(predicate, self.iterator))\n\n def filter_except(self, validate: Unary[T, Any], *errors: AnyErrorType) -> Iter[T]:\n return self.create(filter_except(validate, self.iterator, *errors))\n\n def compress(self, selectors: Selectors) -> Iter[T]:\n return self.create(compress(self.iterator, selectors))\n\n def position_all(self, predicate: Optional[Predicate[T]]) -> Iter[int]:\n return self.create(position_all(predicate, self.iterator))\n\n def position(self, predicate: Optional[Predicate[T]]) -> Option[int]:\n return wrap_marked(position(predicate, self.iterator, marker))\n\n def find_all(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(find_all(predicate, self.iterator))\n\n def find(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(find(predicate, self.iterator, marker)) # type: ignore # weird\n\n def find_or_first(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(find_or_first(predicate, self.iterator, marker)) # type: ignore # weird\n\n def find_or_last(self, predicate: Optional[Predicate[T]]) -> Option[T]:\n return wrap_marked(find_or_last(predicate, self.iterator, marker)) # type: ignore # weird\n\n def contains(self, item: V) -> bool:\n return contains(item, self.iterator)\n\n def contains_identity(self: Iter[V], item: V) -> bool:\n return contains_identity(item, self.iterator)\n\n def reduce(self, function: Binary[T, T, T]) -> Option[T]:\n return wrap_marked(reduce(function, self.iterator, marker)) # type: ignore # weird\n\n def fold(self, initial: V, function: Binary[V, T, V]) -> V:\n return fold(initial, function, self.iterator)\n\n @early_option\n def sum(self: Iter[S]) -> Option[S]:\n return Some(self.sum_with(self.next().early()))\n\n def sum_with(self: Iter[S], initial: S) -> S:\n return sum(self.iterator, initial)\n\n @early_option\n def product(self: Iter[P]) -> Option[P]:\n return Some(self.product_with(self.next().early()))\n\n def product_with(self: Iter[P], initial: P) -> P:\n return product(self.iterator, initial)\n\n def accumulate_reduce(self, function: Binary[T, T, T]) -> Iter[T]:\n return self.create(accumulate_reduce(function, self.iterator))\n\n def accumulate_fold(self, initial: V, function: Binary[V, T, V]) -> Iter[V]:\n return self.create(accumulate_fold(initial, function, self.iterator))\n\n def accumulate_sum(self: Iter[S]) -> Iter[S]:\n return self.create(accumulate_sum(self.iterator))\n\n def accumulate_sum_with(self: Iter[S], initial: S) -> Iter[S]:\n return self.create(accumulate_sum(self.iterator, initial))\n\n def accumulate_product(self: Iter[P]) -> Iter[P]:\n return self.create(accumulate_product(self.iterator))\n\n def accumulate_product_with(self: Iter[P], initial: P) -> Iter[P]:\n return self.create(accumulate_product(self.iterator, initial))\n\n def min(self: Iter[ST]) -> Option[ST]:\n return wrap_marked(min(self.iterator, default=marker))\n\n def min_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(min(self.iterator, key=key, default=marker)) # type: ignore # weird\n\n def max(self: Iter[ST]) -> Option[ST]:\n return wrap_marked(max(self.iterator, default=marker))\n\n def max_by(self, key: Unary[T, ST]) -> Option[T]:\n return wrap_marked(max(self.iterator, key=key, default=marker)) # type: ignore # weird\n\n def min_max(self: Iter[ST]) -> Option[Pair[ST]]:\n return wrap_marked(min_max(self.iterator, default=marker))\n\n def min_max_by(self, key: Unary[T, ST]) -> Option[Pair[T]]:\n return wrap_marked(min_max(self.iterator, key=key, default=marker))\n\n def map(self, function: Unary[T, U]) -> Iter[U]:\n return self.create(map(function, self.iterator))\n\n def map_except(self, function: Unary[T, U], *errors: AnyErrorType) -> Iter[U]:\n return self.create(map_except(function, self.iterator, *errors))\n\n def flat_map(self, function: Unary[T, Iterable[U]]) -> Iter[U]:\n return self.create(flat_map(function, self.iterator))\n\n def filter_map(self, predicate: Optional[Predicate[T]], function: Unary[T, U]) -> Iter[U]:\n return self.create(filter_map(predicate, function, self.iterator))\n\n def filter_false_map(self, predicate: Optional[Predicate[T]], function: Unary[T, U]) -> Iter[U]:\n return self.create(filter_false_map(predicate, function, self.iterator))\n\n def flatten(self: Iter[Iterable[U]]) -> Iter[U]:\n return self.create(flatten(self.iterator))\n\n def collapse(self: Iter[RecursiveIterable[U]]) -> Iter[U]:\n return self.create(collapse(self.iterator))\n\n def enumerate(self) -> Iter[Tuple[int, T]]:\n return self.create(enumerate(self.iterator))\n\n def enumerate_from(self, start: int) -> Iter[Tuple[int, T]]:\n return self.create(enumerate(self.iterator, start))\n\n def consume(self) -> None:\n consume(self.iterator)\n\n def for_each(self, function: Unary[T, Any]) -> None:\n for_each(function, self.iterator)\n\n def append(self: Iter[V], item: V) -> Iter[V]:\n return self.create(append(item, self.iterator))\n\n def prepend(self: Iter[V], item: V) -> Iter[V]:\n return self.create(prepend(item, self.iterator))\n\n def at(self, index: int) -> Option[T]:\n return wrap_marked(at(index, self.iterator, marker))\n\n def at_or_last(self, index: int) -> Option[T]:\n return wrap_marked(at_or_last(index, self.iterator, marker))\n\n @overload\n def slice(self, __stop: Optional[int]) -> Iter[T]:\n ...\n\n @overload\n def slice(\n self, __start: Optional[int], __stop: Optional[int], __step: Optional[int] = ...\n ) -> Iter[T]:\n ...\n\n def slice(self, *slice_args: Optional[int]) -> Iter[T]:\n return self.create(iter_slice(self.iterator, *slice_args))\n\n def drop(self, size: int) -> Iter[T]:\n return self.create(drop(size, self.iterator))\n\n skip = drop\n\n def rest(self) -> Iter[T]:\n return self.create(rest(self.iterator))\n\n def drop_while(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(drop_while(predicate, self.iterator))\n\n skip_while = drop_while\n\n def take(self, size: int) -> Iter[T]:\n return self.create(take(size, self.iterator))\n\n def take_while(self, predicate: Optional[Predicate[T]]) -> Iter[T]:\n return self.create(take_while(predicate, self.iterator))\n\n def step_by(self, step: int) -> Iter[T]:\n return self.create(step_by(step, self.iterator))\n\n def tail(self, size: int) -> Iter[T]:\n return self.create(tail(size, self.iterator))\n\n def apply_chain(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(chain(self.iterator, *iterables))\n\n chain = mixed_method(create_chain, apply_chain)\n\n def apply_chain_with(self, iterables: Iterable[Iterable[T]]) -> Iter[T]:\n return self.chain(chain_from_iterable(iterables))\n\n chain_with = mixed_method(create_chain_with, apply_chain_with)\n\n def cycle(self) -> Iter[T]:\n return self.create(cycle(self.iterator))\n\n def intersperse(self: Iter[V], value: V) -> Iter[V]:\n return self.create(intersperse(value, self.iterator))\n\n def intersperse_with(self, function: Nullary[T]) -> Iter[T]:\n return self.create(intersperse_with(function, self.iterator))\n\n def apply_interleave(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(interleave(self.iterator, *iterables))\n\n interleave = mixed_method(create_interleave, apply_interleave)\n\n def apply_interleave_longest(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(interleave_longest(self.iterator, *iterables))\n\n interleave_longest = mixed_method(create_interleave_longest, apply_interleave_longest)\n\n def apply_combine(self, *iterables: Iterable[T]) -> Iter[T]:\n return self.create(combine(self.iterator, *iterables))\n\n combine = mixed_method(create_combine, apply_combine)\n\n @overload\n def distribute_unsafe(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[1]) -> Tuple1[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[2]) -> Tuple2[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[3]) -> Tuple3[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[4]) -> Tuple4[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[5]) -> Tuple5[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[6]) -> Tuple6[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[7]) -> Tuple7[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: Literal[8]) -> Tuple8[Iter[T]]:\n ...\n\n @overload\n def distribute_unsafe(self, count: int) -> DynamicTuple[Iter[T]]:\n ...\n\n def distribute_unsafe(self, count: int) -> DynamicTuple[Iter[T]]:\n return self.create_tuple(distribute_unsafe(count, self.iterator))\n\n distribute_infinite = distribute_unsafe\n\n @overload\n def distribute(self, count: Literal[0]) -> EmptyTuple:\n ...\n\n @overload\n def distribute(self, count: Literal[1]) -> Tuple1[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[2]) -> Tuple2[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[3]) -> Tuple3[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[4]) -> Tuple4[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[5]) -> Tuple5[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[6]) -> Tuple6[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[7]) -> Tuple7[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: Literal[8]) -> Tuple8[Iter[T]]:\n ...\n\n @overload\n def distribute(self, count: int) -> DynamicTuple[Iter[T]]:\n ...\n\n def distribute(self, count: int) -> DynamicTuple[Iter[T]]:\n return self.create_tuple(distribute(count, self.iterator))\n\n def divide(self, count: int) -> Iter[Iter[T]]:\n return self.create_nested(divide(count, self.iterator))\n\n def pad(self: Iter[V], value: V) -> Iter[V]:\n return self.create(pad(value, self.iterator))\n\n def pad_exactly(self: Iter[V], value: V, size: int) -> Iter[V]:\n return self.create(pad(value, self.iterator, size))\n\n def pad_multiple(self: Iter[V], value: V, size: int) -> Iter[V]:\n return self.create(pad(value, self.iterator, size, multiple=True))\n\n def pad_with(self: Iter[V], function: Unary[int, V]) -> Iter[V]:\n return self.create(pad_with(function, self.iterator))\n\n def pad_exactly_with(self: Iter[V], function: Unary[int, V], size: int) -> Iter[V]:\n return self.create(pad_with(function, self.iterator, size))\n\n def pad_multiple_with(self: Iter[V], function: Unary[int, V], size: int) -> Iter[V]:\n return self.create(pad_with(function, self.iterator, size, multiple=True))\n\n def chunks(self, size: int) -> Iter[List[T]]:\n return self.create(chunks(size, self.iterator))\n\n def iter_chunks(self, size: int) -> Iter[Iter[T]]:\n return self.create_nested(iter_chunks(size, self.iterator))\n\n def iter_chunks_unsafe(self, size: int) -> Iter[Iter[T]]:\n return self.create_nested(iter_chunks_unsafe(size, self.iterator))\n\n iter_chunks_infinite = iter_chunks_unsafe\n\n @overload\n def groups(self, size: Literal[0]) -> Iter[Never]:\n ...\n\n @overload\n def groups(self, size: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def groups(self, size: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def groups(self, size: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def groups(self, size: int) -> Iter[DynamicTuple[T]]:\n return self.create(groups(size, self.iterator))\n\n @overload\n def groups_longest(self, size: Literal[0]) -> Iter[Never]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[1]) -> Iter[Tuple1[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[2]) -> Iter[Tuple2[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[3]) -> Iter[Tuple3[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[4]) -> Iter[Tuple4[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[5]) -> Iter[Tuple5[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[6]) -> Iter[Tuple6[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[7]) -> Iter[Tuple7[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: Literal[8]) -> Iter[Tuple8[Option[T]]]:\n ...\n\n @overload\n def groups_longest(self, size: int) -> Iter[DynamicTuple[Option[T]]]:\n ...\n\n def groups_longest(self, size: int) -> Iter[DynamicTuple[Option[T]]]:\n return self.create(groups_longest(size, self.iterator))\n\n def pairs(self) -> Iter[Pair[T]]:\n return self.create(pairs(self.iterator))\n\n def pairs_longest(self) -> Iter[Pair[Option[T]]]:\n return self.create(pairs_longest(self.iterator))\n\n def iter_windows(self, size: int) -> Iter[Iter[T]]:\n return self.create_nested(iter_windows(size, self.iterator))\n\n def list_windows(self, size: int) -> Iter[List[T]]:\n return self.create(list_windows(size, self.iterator))\n\n def pairs_windows(self) -> Iter[Pair[T]]:\n return self.create(pairs_windows(self.iterator))\n\n @overload\n def tuple_windows(self, size: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def tuple_windows(self, size: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def tuple_windows(self, size: int) -> Iter[DynamicTuple[T]]:\n return self.create(tuple_windows(size, self.iterator))\n\n def set_windows(self: Iter[Q], size: int) -> Iter[Set[Q]]:\n return self.create(set_windows(size, self.iterator))\n\n @overload\n def apply_zip(self) -> Iter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip(self, __iterable_a: Iterable[A]) -> Iter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n def apply_zip(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n return self.create(zip(self.iterator, *iterables))\n\n zip = mixed_method(create_zip, apply_zip)\n\n @overload\n def apply_zip_equal(self) -> Iter[Tuple[T]]:\n ...\n\n @overload\n def apply_zip_equal(self, __iterable_a: Iterable[A]) -> Iter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_zip_equal(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_zip_equal(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_zip_equal(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_zip_equal( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n def apply_zip_equal(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n return self.create(zip_equal(self.iterator, *iterables))\n\n zip_equal = mixed_method(create_zip_equal, apply_zip_equal)\n\n @overload\n def apply_zip_longest(self) -> Iter[Tuple[Option[T]]]:\n ...\n\n @overload\n def apply_zip_longest(self, __iterable_a: Iterable[A]) -> Iter[Tuple[Option[T], Option[A]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[Option[T], Option[A], Option[B]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D], Option[E]]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D], Option[E], Option[F],]]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[\n Tuple[\n Option[T],\n Option[A],\n Option[B],\n Option[C],\n Option[D],\n Option[E],\n Option[F],\n Option[G],\n Option[H],\n ]\n ]:\n ...\n\n @overload\n def apply_zip_longest( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Option[Any]]]:\n ...\n\n def apply_zip_longest(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]:\n return self.create(zip_longest(self.iterator, *iterables))\n\n zip_longest = mixed_method(create_zip_longest, apply_zip_longest)\n\n def transpose(self: Iter[Iterable[U]]) -> Iter[DynamicTuple[U]]:\n return self.create(transpose(self.iterator))\n\n @overload\n def apply_cartesian_product(self) -> Iter[Tuple[T]]:\n ...\n\n @overload\n def apply_cartesian_product(self, __iterable_a: Iterable[A]) -> Iter[Tuple[T, A]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B]\n ) -> Iter[Tuple[T, A, B]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self, __iterable_a: Iterable[A], __iterable_b: Iterable[B], __iterable_c: Iterable[C]\n ) -> Iter[Tuple[T, A, B, C]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n ) -> Iter[Tuple[T, A, B, C, D]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n ) -> Iter[Tuple[T, A, B, C, D, E]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n ) -> Iter[Tuple[T, A, B, C, D, E, F]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G]]:\n ...\n\n @overload\n def apply_cartesian_product(\n self,\n __iterable_a: Iterable[A],\n __iterable_b: Iterable[B],\n __iterable_c: Iterable[C],\n __iterable_d: Iterable[D],\n __iterable_e: Iterable[E],\n __iterable_f: Iterable[F],\n __iterable_g: Iterable[G],\n __iterable_h: Iterable[H],\n ) -> Iter[Tuple[T, A, B, C, D, E, F, G, H]]:\n ...\n\n @overload\n def apply_cartesian_product( # type: ignore\n self,\n __iterable_a: Iterable[Any],\n __iterable_b: Iterable[Any],\n __iterable_c: Iterable[Any],\n __iterable_d: Iterable[Any],\n __iterable_e: Iterable[Any],\n __iterable_f: Iterable[Any],\n __iterable_g: Iterable[Any],\n __iterable_h: Iterable[Any],\n __iterable_n: Iterable[Any],\n *iterables: Iterable[Any],\n ) -> Iter[DynamicTuple[Any]]:\n ...\n\n def apply_cartesian_product(self, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n return self.create(cartesian_product(self.iterator, *iterables))\n\n cartesian_product = mixed_method(create_cartesian_product, apply_cartesian_product)\n\n @overload\n def cartesian_power(self, power: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def cartesian_power(self, power: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n def cartesian_power(self, power: int) -> Iter[DynamicTuple[T]]:\n \"\"\"Creates an iterator over the\n [*Cartesian power*](https://en.wikipedia.org/wiki/Cartesian_product) of the iterator.\n\n Warning:\n It only makes sense to compute the Cartesian power of finite iterators.\n\n Example:\n ```python\n bits = (0, 1)\n result = ((0, 0), (0, 1), (1, 0), (1, 1))\n\n iterator = iter(bits)\n\n assert iterator.cartesian_power(2).tuple() == result\n ```\n\n Arguments:\n power: The power to \"raise\" the iterator to.\n\n Returns:\n An [`Iter[Tuple[...]]`] over the Cartesian power of the iterator.\n \"\"\"\n return self.create(cartesian_power(power, self.iterator))\n\n @overload\n def combinations(self, count: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def combinations(self, count: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def combinations(self, count: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def combinations(self, count: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def combinations(self, count: int) -> Iter[DynamicTuple[T]]:\n return self.create(combinations(count, self.iterator))\n\n @overload\n def combinations_with_replacement(self, count: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def combinations_with_replacement(self, count: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def combinations_with_replacement(self, count: int) -> Iter[DynamicTuple[T]]:\n return self.create(combinations_with_replacement(count, self.iterator))\n\n def permute(self) -> Iter[DynamicTuple[T]]:\n return self.create(permute(self.iterator))\n\n @overload\n def permutations(self, count: Literal[0]) -> Iter[EmptyTuple]:\n ...\n\n @overload\n def permutations(self, count: Literal[1]) -> Iter[Tuple1[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[2]) -> Iter[Tuple2[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[3]) -> Iter[Tuple3[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[4]) -> Iter[Tuple4[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[5]) -> Iter[Tuple5[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[6]) -> Iter[Tuple6[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[7]) -> Iter[Tuple7[T]]:\n ...\n\n @overload\n def permutations(self, count: Literal[8]) -> Iter[Tuple8[T]]:\n ...\n\n @overload\n def permutations(self, count: int) -> Iter[DynamicTuple[T]]:\n ...\n\n def permutations(self, count: int) -> Iter[DynamicTuple[T]]:\n return self.create(permutations(count, self.iterator))\n\n def power_set(self) -> Iter[DynamicTuple[T]]:\n \"\"\"Computes the power set of the iterator.\n\n The power set of $S$ contains all subsets of $S$, including\n the empty set $\\\\varnothing$ and $S$ itself.\n The power set is often denoted as $2^S$ since if $|S| = n$, then $|2^S| = 2^n$.\n\n Returns:\n An iterator over the power set of the iterator.\n \"\"\"\n return self.create(power_set(self.iterator))\n\n def reverse(self) -> Iter[T]:\n return self.create(reverse(self.iterator))\n\n def sorted(self: Iter[ST]) -> List[ST]:\n return sorted(self.iterator)\n\n def sorted_by(self, key: Unary[T, ST]) -> List[T]:\n return sorted(self.iterator, key=key)\n\n def sorted_reverse(self: Iter[ST]) -> List[ST]:\n return sorted(self.iterator, reverse=True)\n\n def sorted_reverse_by(self, key: Unary[T, ST]) -> List[T]:\n return sorted(self.iterator, key=key, reverse=True)\n\n def sort(self: Iter[ST]) -> Iter[ST]:\n return self.create(sort(self.iterator))\n\n def sort_by(self, key: Unary[T, ST]) -> Iter[T]:\n return self.create(sort(self.iterator, key=key))\n\n def sort_reverse(self: Iter[ST]) -> Iter[ST]:\n return self.create(sort(self.iterator, reverse=True))\n\n def sort_reverse_by(self, key: Unary[T, ST]) -> Iter[T]:\n return self.create(sort(self.iterator, key=key, reverse=True))\n\n def is_sorted(self: Iter[LT]) -> bool:\n return is_sorted(self.iterator)\n\n def is_sorted_by(self, key: Unary[T, LT]) -> bool:\n return is_sorted(self.iterator, key)\n\n def is_sorted_reverse(self: Iter[LT]) -> bool:\n return is_sorted(self.iterator, reverse=True)\n\n def is_sorted_reverse_by(self, key: Unary[T, LT]) -> bool:\n return is_sorted(self.iterator, key, reverse=True)\n\n def is_sorted_strict(self: Iter[ST]) -> bool:\n return is_sorted(self.iterator, strict=True)\n\n def is_sorted_strict_by(self, key: Unary[T, ST]) -> bool:\n return is_sorted(self.iterator, key, strict=True)\n\n def is_sorted_reverse_strict(self: Iter[ST]) -> bool:\n return is_sorted(self.iterator, strict=True, reverse=True)\n\n def is_sorted_reverse_strict_by(self, key: Unary[T, ST]) -> bool:\n return is_sorted(self.iterator, key, strict=True, reverse=True)\n\n def duplicates_fast(self: Iter[Q]) -> Iter[Q]:\n return self.create(duplicates_fast(self.iterator))\n\n def duplicates_fast_by(self, key: Unary[T, Q]) -> Iter[T]:\n return self.create(duplicates_fast(self.iterator, key))\n\n def duplicates(self) -> Iter[T]:\n return self.create(duplicates(self.iterator))\n\n def duplicates_by(self, key: Unary[T, V]) -> Iter[T]:\n return self.create(duplicates(self.iterator, key))\n\n def unique_fast(self: Iter[Q]) -> Iter[Q]:\n return self.create(unique_fast(self.iterator))\n\n def unique_fast_by(self, key: Unary[T, Q]) -> Iter[T]:\n return self.create(unique_fast(self.iterator, key))\n\n def unique(self) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator.\n\n This function may be slower than [`unique_fast`][iters.iters.Iter.unique_fast]\n in case `T` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, 1, 0, 1, 1, 1, 0)\n >>> iterator.unique().tuple()\n (0, 1)\n ```\n\n Returns:\n An iterator over the unique items in the iterator.\n \"\"\"\n return self.create(unique(self.iterator))\n\n def unique_by(self, key: Unary[T, V]) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator based on the given `key`.\n\n This function may be slower than [`unique_fast_by`][iters.iters.Iter.unique_fast_by]\n in case `V` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, -1)\n >>> iterator.unique_by(abs).tuple()\n (0, 1)\n ```\n\n Arguments:\n key: The key to use in determining uniqueness.\n\n Returns:\n An iterator over the unique items in the iterator based on the given `key`.\n \"\"\"\n return self.create(unique(self.iterator, key))\n\n def partition(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *safely* based on the given `predicate`,\n loading **all** items into memory!\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_positive(z: int) -> bool:\n return z > 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> positive, non_positive = iterator.partition(is_positive)\n >>> positive.list()\n [1]\n >>> non_positive.list()\n [-1, 0]\n ```\n\n Note:\n This method exhausts the underlying iterator.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n def partition_unsafe(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *unsafely* based on the given `predicate`.\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_negative(z: int) -> bool:\n return z < 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> negative, non_negative = iterator.partition_unsafe(is_negative)\n >>> non_negative.list()\n [0, 1]\n >>> negative.list()\n [-1]\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method works on the underlying iterator, so using the original iterator\n is not recommended after calling this method.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition_unsafe(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n\n partition_infinite = partition_unsafe\n \"\"\"An alias of [`partition_unsafe`][iters.iters.Iter.partition_unsafe],\n since partitioning infinite iterators can only be done *unsafely*.\n \"\"\"\n\n def copy(self) -> Iter[T]:\n \"\"\"Copies the iterator *safely*, loading **all** items into memory!\n\n Example:\n ```python\n >>> iterator = iter.of(1, 2, 3)\n >>> copy = iterator.copy()\n >>> iterator.tuple()\n (1, 2, 3)\n >>> copy.tuple()\n (1, 2, 3)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n\n def copy_unsafe(self) -> Iter[T]:\n \"\"\"Copies the iterator *unsafely*.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> copy = iterator.copy_unsafe()\n >>> iterator.zip(copy).tuple()\n ((13, 13), (42, 42), (69, 69))\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy_unsafe(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n\n copy_infinite = copy_unsafe\n \"\"\"An alias of [`copy_unsafe`][iters.iters.Iter.copy_unsafe],\n since copying infinite iterators can only be done *unsafely*.\n \"\"\"\n\n def spy(self, size: int) -> List[T]:\n \"\"\"Spies on at most `size` next items of the iterator, without consuming them.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.spy(2)\n [13, 34]\n >>> iterator.spy(4)\n [13, 34, 42]\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Arguments:\n size: The amount of items to spy on.\n\n Returns:\n Up to `size` next items of the iterator.\n \"\"\"\n result, iterator = spy(size, self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def peek(self) -> Option[T]:\n \"\"\"Peeks at the next item in the iterator, without consuming it.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.peek()\n Some(13)\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n The next item in the iterator, if one exists.\n \"\"\"\n item, iterator = peek(self.iterator, marker)\n\n self._replace(iterator)\n\n return wrap_marked(item)\n\n def has_next(self) -> bool:\n \"\"\"Checks if the iterator has a next item (i.e. is non-empty).\n\n Example:\n ```python\n >>> assert iter.once(1).has_next()\n >>> assert not iter.empty().has_next()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator has a next item.\n \"\"\"\n result, iterator = has_next(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def is_empty(self) -> bool:\n \"\"\"Checks if the iterator is empty.\n\n Example:\n ```python\n >>> assert iter.empty().is_empty()\n >>> assert not iter.once(0).is_empty()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator is empty.\n \"\"\"\n result, iterator = is_empty(self.iterator)\n\n self._replace(iterator)\n\n return result\n\n def repeat_last(self) -> Iter[T]:\n \"\"\"Repeats the last item of the iterator indefinitely.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1)\n >>> iterator.next()\n Some(0)\n >>> iterator.next()\n Some(1)\n >>> iterator.next()\n Some(1) # now repeating the last item\n ```\n\n Returns:\n The iterator with the last item repeated indefinitely.\n \"\"\"\n return self.create(repeat_last(self.iterator))\n\n def repeat_each(self, count: int) -> Iter[T]:\n \"\"\"Repeat each item of the iterator `count` times.\n\n Example:\n ```python\n >>> iter.of(0, 1).repeat_each(2).tuple()\n (0, 0, 1, 1)\n ```\n\n ```python\n >>> iter.once(0).repeat_each(0).tuple()\n ()\n ```\n\n Arguments:\n count: The amount of times to repeat each item.\n\n Returns:\n The iterator with each item repeated `count` times.\n \"\"\"\n return self.create(repeat_each(count, self.iterator))\n\n def inspect(self, function: Inspect[T]) -> Iter[T]:\n \"\"\"Inspects each item of the iterator with the given `function`.\n\n Example:\n ```python\n >>> iter.of(1, 2, 3).inspect(print).consume()\n 1\n 2\n 3\n ```\n\n Arguments:\n function: The inspecting function.\n\n Returns:\n The original iterator.\n \"\"\"\n return self.create(inspect(function, self.iterator))\n\n def scan(self, state: V, function: Binary[V, T, Option[U]]) -> Iter[U]:\n return self.create(scan(state, function, self.iterator))\n\n def filter_map_option(self, function: Unary[T, Option[U]]) -> Iter[U]:\n return self.create(filter_map_option(function, self.iterator))\n\n # def transpose_option(self: Iter[Option[U]]) -> Option[Iter[U]]:\n # return self.create_option(transpose_option(self.iterator))\n\n def into_async_iter(self) -> AsyncIter[T]:\n \"\"\"Converts an [`Iter[T]`][iters.iters.Iter] into\n an [`AsyncIter[T]`][iters.async_iters.AsyncIter].\n\n Example:\n ```python\n >>> async_iterator = iter.of(13, 34, 42).into_async_iter()\n >>> await async_iterator.tuple()\n (13, 34, 42)\n ```\n\n Returns:\n The async iterator created from the iterator.\n \"\"\"\n return async_iter(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.iterator","title":"iterator: Iterator[T]
property
","text":"The underlying iterator.
"},{"location":"reference/iters/#iters.iters.Iter.partition_infinite","title":"partition_infinite = partition_unsafe
class-attribute
instance-attribute
","text":"An alias of partition_unsafe
, since partitioning infinite iterators can only be done unsafely.
"},{"location":"reference/iters/#iters.iters.Iter.copy_infinite","title":"copy_infinite = copy_unsafe
class-attribute
instance-attribute
","text":"An alias of copy_unsafe
, since copying infinite iterators can only be done unsafely.
"},{"location":"reference/iters/#iters.iters.Iter.empty","title":"empty() -> Iter[T]
classmethod
","text":"Creates an empty iterator.
Example >>> iterator = iter.empty()\n>>> iterator.next()\nNull()\n
Returns:
Type Description Iter[T]
An empty iterator.
Source code in iters/iters.py
@classmethod\ndef empty(cls) -> Iter[T]:\n \"\"\"Creates an empty iterator.\n\n Example:\n ```python\n >>> iterator = iter.empty()\n >>> iterator.next()\n Null()\n ```\n\n Returns:\n An empty iterator.\n \"\"\"\n return cls.create(empty())\n
"},{"location":"reference/iters/#iters.iters.Iter.of","title":"of(*items: V) -> Iter[V]
classmethod
","text":"Creates an iterator from items
.
Example >>> iterator = iter.of(13, 42, 69)\n>>> iterator.next()\nSome(13)\n>>> iterator.next()\nSome(42)\n>>> iterator.next()\nSome(69)\n>>> iterator.next()\nNull()\n
Parameters:
Name Type Description Default *items
V
The items to iterate over.
()
Returns:
Type Description Iter[V]
An iterator over items
.
Source code in iters/iters.py
@classmethod\ndef of(cls, *items: V) -> Iter[V]:\n \"\"\"Creates an iterator from `items`.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> iterator.next()\n Some(13)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Some(69)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n *items: The items to iterate over.\n\n Returns:\n An iterator over `items`.\n \"\"\"\n return cls.create(items)\n
"},{"location":"reference/iters/#iters.iters.Iter.once","title":"once(value: V) -> Iter[V]
classmethod
","text":"Creates an iterator that yields the value
exactly once.
This is commonly used to adapt a single value into a chain
of other kinds of iteration. Maybe you have an iterator that covers almost everything, but you need an extra special case. Maybe you have a function which works on iterators, but you only need to process one value.
Example >>> iterator = iter.once(42)\n>>> iterator.next()\nSome(42)\n>>> iterator.next()\nNull()\n
Parameters:
Name Type Description Default value
V
The value to yield.
required Returns:
Type Description Iter[V]
An Iter[V]
with value
.
Source code in iters/iters.py
@classmethod\ndef once(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that yields the `value` exactly once.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Example:\n ```python\n >>> iterator = iter.once(42)\n >>> iterator.next()\n Some(42)\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n value: The value to yield.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value`.\n \"\"\"\n return cls.create(once(value))\n
"},{"location":"reference/iters/#iters.iters.Iter.once_with","title":"once_with(function: Nullary[V]) -> Iter[V]
classmethod
","text":"Creates an iterator that lazily generates an item exactly once by invoking the function
provided.
This is commonly used to adapt a single value into a chain
of other kinds of iteration. Maybe you have an iterator that covers almost everything, but you need an extra special case. Maybe you have a function which works on iterators, but you only need to process one value.
Unlike once
, this function will lazily generate the item on request.
Example >>> iterator = iter.once_with(tuple)\n>>> iterator.next()\nSome(())\n>>> iterator.next()\nNull()\n
Parameters:
Name Type Description Default function
Nullary[V]
The value-generating function to use.
required Returns:
Type Description Iter[V]
An Iter[V]
with the generated value
.
Source code in iters/iters.py
@classmethod\ndef once_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that lazily generates an item exactly once\n by invoking the `function` provided.\n\n This is commonly used to adapt a single value into a [`chain`][iters.iters.Iter.chain]\n of other kinds of iteration. Maybe you have an iterator that covers almost everything,\n but you need an extra special case. Maybe you have a function which works on iterators,\n but you only need to process one value.\n\n Unlike [`once`][iters.iters.Iter.once], this function will\n lazily generate the item on request.\n\n Example:\n ```python\n >>> iterator = iter.once_with(tuple)\n >>> iterator.next()\n Some(())\n >>> iterator.next()\n Null()\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with the generated `value`.\n \"\"\"\n return cls.create(once_with(function))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat","title":"repeat(value: V) -> Iter[V]
classmethod
","text":"Creates an iterator that endlessly repeats a single value
.
This function repeats a single value over and over again.
Infinite iterators like repeat
are often used with adapters like take
, in order to make them finite.
Example >>> fours = iter.repeat(4)\n>>> fours.next()\nSome(4)\n>>> fours.next()\nSome(4)\n>>> fours.next()\nSome(4)\n>>> # ad infinitum...\n
Parameters:
Name Type Description Default value
V
The value to repeat.
required Returns:
Type Description Iter[V]
An infinite Iter[V]
with repeated value
.
Source code in iters/iters.py
@classmethod\ndef repeat(cls, value: V) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly repeats a single `value`.\n\n This function repeats a single value over and over again.\n\n Infinite iterators like [`repeat`][iters.iters.Iter.repeat]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n >>> fours = iter.repeat(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> fours.next()\n Some(4)\n >>> # ad infinitum...\n ```\n\n Arguments:\n value: The value to repeat.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value`.\n \"\"\"\n return cls.create(repeat(value))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_exactly","title":"repeat_exactly(value: V, count: int) -> Iter[V]
classmethod
","text":"Creates an iterator that repeats a single value
exactly count
times.
This function is a shorthand for iter.repeat(value).take(count)
.
Example # let's only have four fours\niterator = iter.repeat_exactly(4, 4)\n\nassert iterator.list() == [4, 4, 4, 4]\n
Parameters:
Name Type Description Default value
V
The value to repeat.
required count
int
The number of times to repeat the value
.
required Returns:
Type Description Iter[V]
An Iter[V]
with value
repeated count
times.
Source code in iters/iters.py
@classmethod\ndef repeat_exactly(cls, value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that repeats a single `value` exactly `count` times.\n\n This function is a shorthand for [`iter.repeat(value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n # let's only have four fours\n iterator = iter.repeat_exactly(4, 4)\n\n assert iterator.list() == [4, 4, 4, 4]\n ```\n\n Arguments:\n value: The value to repeat.\n count: The number of times to repeat the `value`.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with `value` repeated `count` times.\n \"\"\"\n return cls.create(repeat(value, count))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_with","title":"repeat_with(function: Nullary[V]) -> Iter[V]
classmethod
","text":"Creates an iterator that endlessly generates values.
This function repeats generated values over and over again.
Infinite iterators like repeat_with
are often used with adapters like take
, in order to make them finite.
Example iterator = iter.repeat_with(tuple)\n\nassert iterator.next().unwrap() == ()\nassert iterator.next().unwrap() == ()\nassert iterator.next().unwrap() == ()\n\n# ... ad infinitum\n
Parameters:
Name Type Description Default function
Nullary[V]
The value-generating function to use.
required Returns:
Type Description Iter[V]
An infinite Iter[V]
with repeated value
of type V
.
Source code in iters/iters.py
@classmethod\ndef repeat_with(cls, function: Nullary[V]) -> Iter[V]:\n \"\"\"Creates an iterator that endlessly generates values.\n\n This function repeats generated values over and over again.\n\n Infinite iterators like [`repeat_with`][iters.iters.Iter.repeat_with]\n are often used with adapters like [`take`][iters.iters.Iter.take],\n in order to make them finite.\n\n Example:\n ```python\n iterator = iter.repeat_with(tuple)\n\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n assert iterator.next().unwrap() == ()\n\n # ... ad infinitum\n ```\n\n Arguments:\n function: The value-generating function to use.\n\n Returns:\n An infinite [`Iter[V]`][iters.iters.Iter] with repeated `value` of type `V`.\n \"\"\"\n return cls.create(repeat_with(function))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_exactly_with","title":"repeat_exactly_with(function: Nullary[V], count: int) -> Iter[V]
classmethod
","text":"Creates an iterator that generates values of type V
exactly count
times.
This function is a shorthand for iter.repeat_with(function).take(count)
.
Example assert iter.repeat_exactly_with(tuple, 3).tuple() == ((), (), ()) # tuple triple!\n
Parameters:
Name Type Description Default function
Nullary[V]
The value-generating function to use.
required count
int
The number of times to repeat values.
required Returns:
Type Description Iter[V]
An Iter[V]
with repeated value
of type V
exactly count
times.
Source code in iters/iters.py
@classmethod\ndef repeat_exactly_with(cls, function: Nullary[V], count: int) -> Iter[V]:\n \"\"\"Creates an iterator that generates values of type `V` exactly `count` times.\n\n This function is a shorthand for\n [`iter.repeat_with(function).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n assert iter.repeat_exactly_with(tuple, 3).tuple() == ((), (), ()) # tuple triple!\n ```\n\n Arguments:\n function: The value-generating function to use.\n count: The number of times to repeat values.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] with repeated\n `value` of type `V` exactly `count` times.\n \"\"\"\n return cls.create(repeat_with(function, count))\n
"},{"location":"reference/iters/#iters.iters.Iter.count_from_by","title":"count_from_by(start: int, step: int) -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by step
) values starting from start
.
Example iterator = iter.count_from_by(1, 2)\n\nassert iterator.next() == 1\nassert iterator.next() == 3\nassert iterator.next() == 5\nassert iterator.next() == 7\nassert iterator.next() == 9\n
Parameters:
Name Type Description Default start
int
The value to start from.
required step
int
The value to step by.
required Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count_from_by(cls, start: int, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `start`.\n\n Example:\n ```python\n iterator = iter.count_from_by(1, 2)\n\n assert iterator.next() == 1\n assert iterator.next() == 3\n assert iterator.next() == 5\n assert iterator.next() == 7\n assert iterator.next() == 9\n ```\n\n Arguments:\n start: The value to start from.\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.create(count(start, step))\n
"},{"location":"reference/iters/#iters.iters.Iter.count_from","title":"count_from(start: int) -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by 1
) values starting from start
.
This is a shorthand for:
iter.count_from_by(start, 1)\n
Parameters:
Name Type Description Default start
int
The value to start from.
required Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count_from(cls, start: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `start`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(start, 1)\n ```\n\n Arguments:\n start: The value to start from.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(start, DEFAULT_STEP)\n
"},{"location":"reference/iters/#iters.iters.Iter.count_by","title":"count_by(step: int) -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by step
) values starting from 0
.
This is a shorthand for:
iter.count_from_by(0, step)\n
Parameters:
Name Type Description Default step
int
The value to step by.
required Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count_by(cls, step: int) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `step`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, step)\n ```\n\n Arguments:\n step: The value to step by.\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, step)\n
"},{"location":"reference/iters/#iters.iters.Iter.count","title":"count() -> Iter[int]
classmethod
","text":"Creates an iterator of evenly spaced (by 1
) values starting from 0
.
This is a shorthand for:
iter.count_from_by(0, 1)\n
Returns:
Type Description Iter[int]
An Iter[int]
over evenly spaced values.
Source code in iters/iters.py
@classmethod\ndef count(cls) -> Iter[int]:\n \"\"\"Creates an iterator of evenly spaced (by `1`) values starting from `0`.\n\n This is a shorthand for:\n\n ```python\n iter.count_from_by(0, 1)\n ```\n\n Returns:\n An [`Iter[int]`][iters.iters.Iter] over evenly spaced values.\n \"\"\"\n return cls.count_from_by(DEFAULT_START, DEFAULT_STEP)\n
"},{"location":"reference/iters/#iters.iters.Iter.iterate","title":"iterate(function: Unary[V, V], value: V) -> Iter[V]
classmethod
","text":"Creates an iterator that iterates function calls endlessly, i.e. value
, function(value)
, function(function(value))
, ...
Example zero = 0\n\ndef successor(natural: int) -> int:\n return natural + 1\n\nnaturals = iter.iterate(successor, zero)\n
Parameters:
Name Type Description Default function
Unary[V, V]
The function to iterate.
required value
V
The value to begin iteration with.
required Returns:
Type Description Iter[V]
An Iter[V]
over iteration results.
Source code in iters/iters.py
@classmethod\ndef iterate(cls, function: Unary[V, V], value: V) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls endlessly, i.e. `value`,\n `function(value)`, `function(function(value))`, ...\n\n Example:\n ```python\n zero = 0\n\n def successor(natural: int) -> int:\n return natural + 1\n\n naturals = iter.iterate(successor, zero)\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value))\n
"},{"location":"reference/iters/#iters.iters.Iter.iterate_exactly","title":"iterate_exactly(function: Unary[V, V], value: V, count: int) -> Iter[V]
classmethod
","text":"Creates an iterator that iterates function calls exactly count
times.
This is a shorthand for iter.iterate(function, value).take(count)
.
Example def wrap(item: T) -> List[T]:\n return [item]\n\niter.iterate_exactly(wrap, 13, 5).list() == [\n 13, [13], [[13]], [[[13]]], [[[[13]]]]\n]\n
Parameters:
Name Type Description Default function
Unary[V, V]
The function to iterate.
required value
V
The value to begin iteration with.
required count
int
The amount of function iterations.
required Returns:
Type Description Iter[V]
An Iter[V]
over iteration results.
Source code in iters/iters.py
@classmethod\ndef iterate_exactly(cls, function: Unary[V, V], value: V, count: int) -> Iter[V]:\n \"\"\"Creates an iterator that iterates function calls exactly `count` times.\n\n This is a shorthand for\n [`iter.iterate(function, value).take(count)`][iters.iters.Iter.take].\n\n Example:\n ```python\n def wrap(item: T) -> List[T]:\n return [item]\n\n iter.iterate_exactly(wrap, 13, 5).list() == [\n 13, [13], [[13]], [[[13]]], [[[[13]]]]\n ]\n ```\n\n Arguments:\n function: The function to iterate.\n value: The value to begin iteration with.\n count: The amount of function iterations.\n\n Returns:\n An [`Iter[V]`][iters.iters.Iter] over iteration results.\n \"\"\"\n return cls.create(iterate(function, value, count))\n
"},{"location":"reference/iters/#iters.iters.Iter.iter_except","title":"iter_except(function: Nullary[T], *errors: AnyErrorType) -> Iter[T]
classmethod
","text":"Creates an iterator that repeatedly calls function
until any of the errors
is encountered.
Example An interesting way to reverse arrays:
array = [1, 2, 3]\n\niter.iter_except(array.pop, IndexError).list() == [3, 2, 1]\n
Parameters:
Name Type Description Default function
Nullary[T]
The function to iterate.
required *errors
AnyErrorType
The errors to except
, stopping iteration.
()
Returns:
Type Description Iter[T]
An Iter[T]
over function results.
Source code in iters/iters.py
@classmethod\ndef iter_except(cls, function: Nullary[T], *errors: AnyErrorType) -> Iter[T]:\n \"\"\"Creates an iterator that repeatedly calls `function` until\n any of the `errors` is encountered.\n\n Example:\n An interesting way to reverse arrays:\n\n ```python\n array = [1, 2, 3]\n\n iter.iter_except(array.pop, IndexError).list() == [3, 2, 1]\n ```\n\n Arguments:\n function: The function to iterate.\n *errors: The errors to `except`, stopping iteration.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function results.\n \"\"\"\n return cls.create(iter_except(function, *errors))\n
"},{"location":"reference/iters/#iters.iters.Iter.iter_with","title":"iter_with(context_manager: ContextManager[Iterable[T]]) -> Iter[T]
classmethod
","text":"Creates an iterator over the iterable returned by context_manager
.
This is essentially equivalent to:
def iter_with(context_manager: ContextManager[Iterable[T]]) -> Iterator[T]:\n with context_manager as iterable:\n for item in iterable:\n yield item\n\niterator = iter(iter_with(context_manager))\n
This function can be used to open and close files, for example; let us consider parsing some file containing integers on every line.
Example array = iter.iter_with(open(\"file.in\")).map(int).list()\n
Parameters:
Name Type Description Default context_manager
ContextManager[Iterable[T]]
The context manager returning an iterable.
required Returns:
Type Description Iter[T]
An Iter[T]
over items in an iterable.
Source code in iters/iters.py
@classmethod\ndef iter_with(cls, context_manager: ContextManager[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator over the iterable returned by `context_manager`.\n\n This is essentially equivalent to:\n\n ```python\n def iter_with(context_manager: ContextManager[Iterable[T]]) -> Iterator[T]:\n with context_manager as iterable:\n for item in iterable:\n yield item\n\n iterator = iter(iter_with(context_manager))\n ```\n\n This function can be used to open and close files, for example;\n let us consider parsing some file containing integers on every line.\n\n Example:\n ```python\n array = iter.iter_with(open(\"file.in\")).map(int).list()\n ```\n\n Arguments:\n context_manager: The context manager returning an iterable.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over items in an iterable.\n \"\"\"\n return cls.create(iter_with(context_manager))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_chain","title":"create_chain(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator chaining iterables
together.
For example, it can be used to chain arrays.
Example a = [1, 2, 3]\nb = [4, 5, 6]\nc = [7, 8, 9]\n\nassert iter.create_chain(a, b, c).list() == a + b + c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to chain together.
()
Returns:
Type Description Iter[T]
An Iter[T]
over chained iterables.
Source code in iters/iters.py
@classmethod\ndef create_chain(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator chaining `iterables` together.\n\n For example, it can be used to chain arrays.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [7, 8, 9]\n\n assert iter.create_chain(a, b, c).list() == a + b + c\n ```\n\n Arguments:\n *iterables: Iterables to chain together.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_chain_with","title":"create_chain_with(iterable: Iterable[Iterable[T]]) -> Iter[T]
classmethod
","text":"Creates an iterator chaining iterables in the iterable
together.
This function essentially flattens the iterable
provided.
Example matrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9],\n]\n\nresult = 45\n\nassert iter.create_chain_with(matrix).sum() == result\n
Parameters:
Name Type Description Default iterable
Iterable[Iterable[T]]
The iterable of iterables to chain.
required Returns:
Type Description Iter[T]
An Iter[T]
over chained iterables.
Source code in iters/iters.py
@classmethod\ndef create_chain_with(cls, iterable: Iterable[Iterable[T]]) -> Iter[T]:\n \"\"\"Creates an iterator chaining iterables in the `iterable` together.\n\n This function essentially flattens the `iterable` provided.\n\n Example:\n ```python\n matrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9],\n ]\n\n result = 45\n\n assert iter.create_chain_with(matrix).sum() == result\n ```\n\n Arguments:\n iterable: The iterable of iterables to chain.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over chained iterables.\n \"\"\"\n return cls.create(chain_from_iterable(iterable))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_combine","title":"create_combine(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator combining iterables
.
This method is a slightly different version of create_interleave_longest
.
Example a = [1, 2, 3]\nb = [4, 5, 6]\nc = [1, 4, 2, 5, 3, 6]\n\nassert iter.combine(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to combine.
()
Returns:
Type Description Iter[T]
An Iter[T]
over combined iterables.
Source code in iters/iters.py
@classmethod\ndef create_combine(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator combining `iterables`.\n\n This method is a slightly different version of\n [`create_interleave_longest`][iters.iters.Iter.create_interleave_longest].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.combine(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to combine.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over combined iterables.\n \"\"\"\n return cls.create(combine(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_interleave","title":"create_interleave(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator interleaving iterables
.
Note This method stops when the shortest iterable is exhausted.
Example a = [1, 2, 3]\nb = [4, 5, 6, 7, 8, 9]\nc = [1, 4, 2, 5, 3, 6]\n\nassert iter.create_interleave(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to interleave.
()
Returns:
Type Description Iter[T]
An Iter[T]
over interleft iterables.
Source code in iters/iters.py
@classmethod\ndef create_interleave(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6]\n\n assert iter.create_interleave(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_interleave_longest","title":"create_interleave_longest(*iterables: Iterable[T]) -> Iter[T]
classmethod
","text":"Creates an iterator interleaving iterables
.
This method is a slightly different version of create_combine
.
Example a = [1, 2, 3]\nb = [4, 5, 6, 7, 8, 9]\nc = [1, 4, 2, 5, 3, 6, 7, 8, 9]\n\nassert iter.create_interleave_longest(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[T]
Iterables to interleave.
()
Returns:
Type Description Iter[T]
An Iter[T]
over interleft iterables.
Source code in iters/iters.py
@classmethod\ndef create_interleave_longest(cls, *iterables: Iterable[T]) -> Iter[T]:\n \"\"\"Creates an iterator interleaving `iterables`.\n\n This method is a slightly different version of\n [`create_combine`][iters.iters.Iter.create_combine].\n\n Example:\n ```python\n a = [1, 2, 3]\n b = [4, 5, 6, 7, 8, 9]\n c = [1, 4, 2, 5, 3, 6, 7, 8, 9]\n\n assert iter.create_interleave_longest(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to interleave.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over interleft iterables.\n \"\"\"\n return cls.create(interleave_longest(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_zip","title":"create_zip(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]
classmethod
","text":"Zips iterables
into an iterator of tuples, where the i-th tuple contains the i-th item from each of the iterables.
Note This method stops when the shortest iterable is exhausted.
Example x = (1, 2, 3, 4, 5)\n\ny = \"nekit\"\n\niter.create_zip(x, y).list() == [(1, \"n\"), (2, \"e\"), (3, \"k\"), (4, \"i\"), (5, \"t\")]\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to zip.
()
Returns:
Type Description Iter[DynamicTuple[Any]]
An Iter[Tuple[...]]
over zipped tuples.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_zip(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n Note:\n This method stops when the shortest iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4, 5)\n\n y = \"nekit\"\n\n iter.create_zip(x, y).list() == [(1, \"n\"), (2, \"e\"), (3, \"k\"), (4, \"i\"), (5, \"t\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_zip_equal","title":"create_zip_equal(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]
classmethod
","text":"Zips iterables
into an iterator of tuples, where the i-th tuple contains the i-th item from each of the iterables.
This is the strict version of create_zip
.
Example x = (1, 2, 3)\n\ny = \"dev\"\n\niter.create_zip_equal(x, y).list() == [(1, \"d\"), (2, \"e\"), (3, \"v\")]\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to zip.
()
Raises:
Type Description ValueError
Iterables have different lengths.
Returns:
Type Description Iter[DynamicTuple[Any]]
An Iter[Tuple[...]]
over zipped tuples.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_zip_equal(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is the strict version of [`create_zip`][iters.iters.Iter.create_zip].\n\n Example:\n ```python\n x = (1, 2, 3)\n\n y = \"dev\"\n\n iter.create_zip_equal(x, y).list() == [(1, \"d\"), (2, \"e\"), (3, \"v\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Raises:\n ValueError: Iterables have different lengths.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_equal(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_zip_longest","title":"create_zip_longest(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]
classmethod
","text":"Zips iterables
into an iterator of tuples, where the i-th tuple contains the i-th item from each of the iterables.
This is a version of create_zip
that places None
in place of a j-th item of an i-th tuple when a j-th iterable is exhausted.
Example x = (1, 2, 3, 4)\n\ny = \"dev\"\n\nf = \"x\"\n\ndef process(a: Option[int], b: Option[str]) -> Tuple[int, str]:\n return (a.unwrap_or(0), b.unwrap_or(f))\n\nassert (\n iter.create_zip_longest(x, y)\n .map(unpack_binary(process))\n .list()\n) == [(1, \"d\"), (2, \"e\"), (3, \"v\"), (4, \"x\")]\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to zip.
()
Returns:
Type Description Iter[DynamicTuple[Option[Any]]]
An Iter[Tuple[...]]
over zipped tuples.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_zip_longest(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Option[Any]]]:\n \"\"\"Zips `iterables` into an iterator of tuples, where\n the *i*-th tuple contains the *i*-th item from each of the iterables.\n\n This is a version of [`create_zip`][iters.iters.Iter.create_zip] that places [`None`][None]\n in place of a *j*-th item of an *i*-th tuple when a *j*-th iterable is exhausted.\n\n Example:\n ```python\n x = (1, 2, 3, 4)\n\n y = \"dev\"\n\n f = \"x\"\n\n def process(a: Option[int], b: Option[str]) -> Tuple[int, str]:\n return (a.unwrap_or(0), b.unwrap_or(f))\n\n assert (\n iter.create_zip_longest(x, y)\n .map(unpack_binary(process))\n .list()\n ) == [(1, \"d\"), (2, \"e\"), (3, \"v\"), (4, \"x\")]\n ```\n\n Arguments:\n *iterables: Iterables to zip.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over zipped tuples.\n \"\"\"\n return cls.create(zip_longest(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.create_cartesian_product","title":"create_cartesian_product(*iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]
classmethod
","text":"Creates an iterator over the Cartesian product of iterables
.
Warning It only makes sense to compute the product of finite iterables.
Example a = (1, 2, 3)\nb = \"xyz\"\n\nc = [\n (1, \"x\"), (1, \"y\"), (1, \"z\"),\n (2, \"x\"), (2, \"y\"), (2, \"z\"),\n (3, \"x\"), (3, \"y\"), (3, \"z\"),\n]\n\nassert iter.create_cartesian_product(a, b).list() == c\n
Parameters:
Name Type Description Default *iterables
Iterable[Any]
Iterables to compute the Cartesian product of.
()
Returns:
Type Description Iter[DynamicTuple[Any]]
An Iter[Tuple[...]]
over the Cartesian product of iterables.
Source code in iters/iters.py
@no_type_check\n@classmethod\ndef create_cartesian_product(cls, *iterables: Iterable[Any]) -> Iter[DynamicTuple[Any]]:\n \"\"\"Creates an iterator over the\n [*Cartesian product*](https://en.wikipedia.org/wiki/Cartesian_product) of `iterables`.\n\n Warning:\n It only makes sense to compute the product of finite iterables.\n\n Example:\n ```python\n a = (1, 2, 3)\n b = \"xyz\"\n\n c = [\n (1, \"x\"), (1, \"y\"), (1, \"z\"),\n (2, \"x\"), (2, \"y\"), (2, \"z\"),\n (3, \"x\"), (3, \"y\"), (3, \"z\"),\n ]\n\n assert iter.create_cartesian_product(a, b).list() == c\n ```\n\n Arguments:\n *iterables: Iterables to compute the Cartesian product of.\n\n Returns:\n An [`Iter[Tuple[...]]`][iters.iters.Iter] over the Cartesian product of iterables.\n \"\"\"\n return cls.create(cartesian_product(*iterables))\n
"},{"location":"reference/iters/#iters.iters.Iter.reversed","title":"reversed(reversible: Reversible[T]) -> Iter[T]
classmethod
","text":"Creates an iterator over the reversed reversible
.
Example assert iter.reversed([1, 2, 3]).list() == [3, 2, 1]\n
Parameters:
Name Type Description Default reversible
Reversible[T]
The reversible to reverse.
required Returns:
Type Description Iter[T]
An Iter[T]
over the reversed reversible.
Source code in iters/iters.py
@classmethod\ndef reversed(cls, reversible: Reversible[T]) -> Iter[T]:\n \"\"\"Creates an iterator over the reversed `reversible`.\n\n Example:\n ```python\n assert iter.reversed([1, 2, 3]).list() == [3, 2, 1]\n ```\n\n Arguments:\n reversible: The reversible to reverse.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over the reversed reversible.\n \"\"\"\n return cls.create(standard_reversed(reversible))\n
"},{"location":"reference/iters/#iters.iters.Iter.function","title":"function(function: Nullary[T], sentinel: V) -> Iter[T]
classmethod
","text":"Creates an iterator over function
call results until it returns the sentinel
.
Example EMPTY_BYTES = bytes()\n\nREAD_BINARY = \"rb\"\n\nCHUNK_SIZE = 65536\n\ndef read_chunk(file: BinaryIO) -> Nullary[bytes]:\n def reader(size: int = CHUNK_SIZE) -> bytes:\n return file.read(size)\n\n return reader\n\nwith path.open(READ_BINARY) as file:\n iter.function(read_chunk(file), EMPTY_BYTES).for_each(process_chunk)\n
Parameters:
Name Type Description Default function
Nullary[T]
The function to iterate.
required sentinel
V
The sentinel to stop at.
required Returns:
Type Description Iter[T]
An Iter[T]
over function calls until the sentinel
is met.
Source code in iters/iters.py
@classmethod\ndef function(cls, function: Nullary[T], sentinel: V) -> Iter[T]:\n \"\"\"Creates an iterator over `function` call results until it returns the `sentinel`.\n\n Example:\n ```python\n EMPTY_BYTES = bytes()\n\n READ_BINARY = \"rb\"\n\n CHUNK_SIZE = 65536\n\n def read_chunk(file: BinaryIO) -> Nullary[bytes]:\n def reader(size: int = CHUNK_SIZE) -> bytes:\n return file.read(size)\n\n return reader\n\n with path.open(READ_BINARY) as file:\n iter.function(read_chunk(file), EMPTY_BYTES).for_each(process_chunk)\n ```\n\n Arguments:\n function: The function to iterate.\n sentinel: The sentinel to stop at.\n\n Returns:\n An [`Iter[T]`][iters.iters.Iter] over function calls until the `sentinel` is met.\n \"\"\"\n return cls.create(iter_function(function, sentinel))\n
"},{"location":"reference/iters/#iters.iters.Iter.unwrap","title":"unwrap() -> Iterator[T]
","text":"Unwraps the underlying iterator.
Returns:
Type Description Iterator[T]
The underlying iterator.
Source code in iters/iters.py
def unwrap(self) -> Iterator[T]:\n \"\"\"Unwraps the underlying iterator.\n\n Returns:\n The underlying iterator.\n \"\"\"\n return self.iterator\n
"},{"location":"reference/iters/#iters.iters.Iter.iter","title":"iter() -> Iter[T]
","text":"Simply returns self
.
Returns:
Type Description Iter[T]
self
, the current iterator.
Source code in iters/iters.py
def iter(self) -> Iter[T]:\n \"\"\"Simply returns `self`.\n\n Returns:\n `self`, the current iterator.\n \"\"\"\n return self\n
"},{"location":"reference/iters/#iters.iters.Iter.next","title":"next() -> Option[T]
","text":"Returns the next item in the iterator.
Example value = 42\n\niterator = iter.once(value)\n\nassert iterator.next().unwrap() is value\n
Returns:
Type Description Option[T]
The next item.
Source code in iters/iters.py
def next(self) -> Option[T]:\n \"\"\"Returns the next item in the iterator.\n\n Example:\n ```python\n value = 42\n\n iterator = iter.once(value)\n\n assert iterator.next().unwrap() is value\n ```\n\n Returns:\n The next item.\n \"\"\"\n return wrap_marked(next(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.compare","title":"compare(other: Iterable[ST]) -> Ordering
","text":"Compares self
with the other
iterable.
Example array = [1, 2, 3]\n\niterator = iter(array)\n\nassert iterator.compare(array).is_equal()\n
Parameters:
Name Type Description Default other
Iterable[ST]
The other iterable.
required Returns:
Type Description Ordering
The Ordering
representing the result.
Source code in iters/iters.py
def compare(self: Iter[ST], other: Iterable[ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable.\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.compare(array).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other)\n
"},{"location":"reference/iters/#iters.iters.Iter.compare_by","title":"compare_by(other: Iterable[T], key: Unary[T, ST]) -> Ordering
","text":"Compares self
with the other
iterable using the key
function.
Example array = [13, 34, 42]\nnegative = [-x for x in array]\n\niterator = iter(array)\n\nassert iterator.compare_by(negative, abs).is_equal()\n
Parameters:
Name Type Description Default other
Iterable[T]
The other iterable.
required key
Unary[T, ST]
The key function.
required Returns:
Type Description Ordering
The Ordering
representing the result.
Source code in iters/iters.py
def compare_by(self, other: Iterable[T], key: Unary[T, ST]) -> Ordering:\n \"\"\"Compares `self` with the `other` iterable using the `key` function.\n\n Example:\n ```python\n array = [13, 34, 42]\n negative = [-x for x in array]\n\n iterator = iter(array)\n\n assert iterator.compare_by(negative, abs).is_equal()\n ```\n\n Arguments:\n other: The other iterable.\n key: The key function.\n\n Returns:\n The [`Ordering`][iters.types.Ordering] representing the result.\n \"\"\"\n return compare(self.iterator, other, key)\n
"},{"location":"reference/iters/#iters.iters.Iter.length","title":"length() -> int
","text":"Computes the length of the iterator.
Example assert iter.repeat_exactly(7, 7).length() == 7\n
Warning This function exhausts the underlying iterator!
Returns:
Type Description int
The length of the iterator.
Source code in iters/iters.py
def length(self) -> int:\n \"\"\"Computes the length of the iterator.\n\n Example:\n ```python\n assert iter.repeat_exactly(7, 7).length() == 7\n ```\n\n Warning:\n This function exhausts the underlying iterator!\n\n Returns:\n The length of the iterator.\n \"\"\"\n return iter_length(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.first","title":"first() -> Option[T]
","text":"Returns the first item in the iterator.
Example value = 69\n\niterator = iter.once(value)\n\nassert iterator.first().unwrap() is value\n
Returns:
Type Description Option[T]
The first item.
Source code in iters/iters.py
def first(self) -> Option[T]:\n \"\"\"Returns the first item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.first().unwrap() is value\n ```\n\n Returns:\n The first item.\n \"\"\"\n return wrap_marked(first(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.last","title":"last() -> Option[T]
","text":"Returns the last item in the iterator.
Example value = 69\n\niterator = iter.once(value)\n\nassert iterator.last().unwrap() is value\n
Returns:
Type Description Option[T]
The last item.
Source code in iters/iters.py
def last(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.last_with_tail","title":"last_with_tail() -> Option[T]
","text":"Returns the last item in the iterator.
Note This method uses the tail
function.
Example value = 69\n\niterator = iter.once(value)\n\nassert iterator.last_with_tail().unwrap() is value\n
Returns:
Type Description Option[T]
The last item.
Source code in iters/iters.py
def last_with_tail(self) -> Option[T]:\n \"\"\"Returns the last item in the iterator.\n\n Note:\n This method uses the [`tail`][iters.utils.tail] function.\n\n Example:\n ```python\n value = 69\n\n iterator = iter.once(value)\n\n assert iterator.last_with_tail().unwrap() is value\n ```\n\n Returns:\n The last item.\n \"\"\"\n return wrap_marked(last_with_tail(self.iterator, marker))\n
"},{"location":"reference/iters/#iters.iters.Iter.collect","title":"collect(function: Unary[Iterable[T], U]) -> U
","text":"Collects the iterator with the function
.
This is equivalent to:
function(iterator.unwrap())\n
Example array = [1, 2, 3]\n\niterator = iter(array)\n\nassert iterator.collect(list) == array\n
Parameters:
Name Type Description Default function
Unary[Iterable[T], U]
The function to use.
required Returns:
Type Description U
The result of the function
call.
Source code in iters/iters.py
def collect(self, function: Unary[Iterable[T], U]) -> U:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n function(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.collect(list) == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call.\n \"\"\"\n return function(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.collect_iter","title":"collect_iter(function: Unary[Iterable[T], Iterable[U]]) -> Iter[U]
","text":"Collects the iterator with the function
.
This is equivalent to:
iterator.create(iterator.collect(function))\n
Example from typing import TypeVar\n\nT = TypeVar(\"T\")\n\ndef identity(item: T) -> T:\n return item\n\narray = [13, 25, 34]\n\niterator = iter(array).collect_iter(identity)\n\nassert iterator.list() == array\n
Parameters:
Name Type Description Default function
Unary[Iterable[T], Iterable[U]]
The function to use.
required Returns:
Type Description Iter[U]
The result of the function
call, wrapped back into an iterator.
Source code in iters/iters.py
def collect_iter(self, function: Unary[Iterable[T], Iterable[U]]) -> Iter[U]:\n \"\"\"Collects the iterator with the `function`.\n\n This is equivalent to:\n\n ```python\n iterator.create(iterator.collect(function))\n ```\n\n Example:\n ```python\n from typing import TypeVar\n\n T = TypeVar(\"T\")\n\n def identity(item: T) -> T:\n return item\n\n array = [13, 25, 34]\n\n iterator = iter(array).collect_iter(identity)\n\n assert iterator.list() == array\n ```\n\n Arguments:\n function: The function to use.\n\n Returns:\n The result of the `function` call, wrapped back into an iterator.\n \"\"\"\n return self.create(self.collect(function))\n
"},{"location":"reference/iters/#iters.iters.Iter.list","title":"list() -> List[T]
","text":"Collects the iterator into the List[T]
.
This is equivalent to:
list(iterator.unwrap())\n
Example array = [1, 2, 3]\n\niterator = iter(array)\n\nassert iterator.list() == array\n
Returns:
Type Description List[T]
The List[T]
over the iterator.
Source code in iters/iters.py
def list(self) -> List[T]:\n \"\"\"Collects the iterator into the [`List[T]`][list].\n\n This is equivalent to:\n\n ```python\n list(iterator.unwrap())\n ```\n\n Example:\n ```python\n array = [1, 2, 3]\n\n iterator = iter(array)\n\n assert iterator.list() == array\n ```\n\n Returns:\n The [`List[T]`][list] over the iterator.\n \"\"\"\n return list(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.set","title":"set() -> Set[Q]
","text":"Collects the iterator into the Set[Q]
.
Warning The items of the iterator have to be hashable for this method to work.
This is equivalent to:
set(iterator.unwrap())\n
Example set = {13, 42, 69}\n\niterator = iter(set)\n\nassert iterator.set() == set\n
Returns:
Type Description Set[Q]
The Set[Q]
over the iterator.
Source code in iters/iters.py
def set(self: Iter[Q]) -> Set[Q]:\n \"\"\"Collects the iterator into the [`Set[Q]`][set].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n set(iterator.unwrap())\n ```\n\n Example:\n ```python\n set = {13, 42, 69}\n\n iterator = iter(set)\n\n assert iterator.set() == set\n ```\n\n Returns:\n The [`Set[Q]`][set] over the iterator.\n \"\"\"\n return set(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.ordered_set","title":"ordered_set() -> OrderedSet[Q]
","text":"Collects the iterator into the OrderedSet[Q]
.
Warning The items of the iterator have to be hashable for this method to work.
This is equivalent to:
ordered_set(iterator.unwrap())\n
Example ordered_set = OrderedSet([13, 42, 69])\n\niterator = iter(ordered_set)\n\nassert iterator.ordered_set() == ordered_set\n
Returns:
Type Description OrderedSet[Q]
The OrderedSet[Q]
over the iterator.
Source code in iters/iters.py
def ordered_set(self: Iter[Q]) -> OrderedSet[Q]:\n \"\"\"Collects the iterator into the [`OrderedSet[Q]`][iters.ordered_set.OrderedSet].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n ordered_set(iterator.unwrap())\n ```\n\n Example:\n ```python\n ordered_set = OrderedSet([13, 42, 69])\n\n iterator = iter(ordered_set)\n\n assert iterator.ordered_set() == ordered_set\n ```\n\n Returns:\n The [`OrderedSet[Q]`][iters.ordered_set.OrderedSet] over the iterator.\n \"\"\"\n return ordered_set(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.tuple","title":"tuple() -> DynamicTuple[T]
","text":"Collects the iterator into the Tuple[T, ...]
.
This is equivalent to:
tuple(iterator.unwrap())\n
Example tuple = (-1, 0, 1)\n\niterator = iter(tuple)\n\nassert iterator.tuple() == tuple\n
Returns:
Type Description DynamicTuple[T]
The Tuple[T, ...]
over the iterator.
Source code in iters/iters.py
def tuple(self) -> DynamicTuple[T]:\n \"\"\"Collects the iterator into the [`Tuple[T, ...]`][tuple].\n\n This is equivalent to:\n\n ```python\n tuple(iterator.unwrap())\n ```\n\n Example:\n ```python\n tuple = (-1, 0, 1)\n\n iterator = iter(tuple)\n\n assert iterator.tuple() == tuple\n ```\n\n Returns:\n The [`Tuple[T, ...]`][tuple] over the iterator.\n \"\"\"\n return tuple(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.dict","title":"dict() -> Dict[Q, V]
","text":"Collects the iterator into the Dict[Q, V]
.
Warning The first item in each couple has to be hashable for this method to work.
This is equivalent to:
dict(iterator.unwrap())\n
Example mapping = {13: \"nekit\", 42: \"dev\"}\n\niterator = iter(mapping.items())\n\nassert iterator.dict() == mapping\n
Returns:
Type Description Dict[Q, V]
The Dict[Q, V]
over the iterator.
Source code in iters/iters.py
def dict(self: Iter[Tuple[Q, V]]) -> Dict[Q, V]:\n \"\"\"Collects the iterator into the [`Dict[Q, V]`][dict].\n\n Warning:\n The first item in each couple has to be hashable for this method to work.\n\n This is equivalent to:\n\n ```python\n dict(iterator.unwrap())\n ```\n\n Example:\n ```python\n mapping = {13: \"nekit\", 42: \"dev\"}\n\n iterator = iter(mapping.items())\n\n assert iterator.dict() == mapping\n ```\n\n Returns:\n The [`Dict[Q, V]`][dict] over the iterator.\n \"\"\"\n return dict(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.join","title":"join(string: AnyStr) -> AnyStr
","text":"Joins the iterator using the string
.
Warning The iterator must contain only string items for this method to work.
This is equivalent to:
string.join(iterator.unwrap())\n
Example result = \"melody, nekit\"\n\nstring = \", \"\n\niterator = iter(result.split(string))\n\nassert iterator.join(string) == result\n
Returns:
Type Description AnyStr
The joined str
or bytes
depending on the string
type.
Source code in iters/iters.py
def join(self: Iter[AnyStr], string: AnyStr) -> AnyStr:\n \"\"\"Joins the iterator using the `string`.\n\n Warning:\n The iterator must contain only string items for this method to work.\n\n This is equivalent to:\n\n ```python\n string.join(iterator.unwrap())\n ```\n\n Example:\n ```python\n result = \"melody, nekit\"\n\n string = \", \"\n\n iterator = iter(result.split(string))\n\n assert iterator.join(string) == result\n ```\n\n Returns:\n The joined [`str`][str] or [`bytes`][bytes] depending on the `string` type.\n \"\"\"\n return string.join(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.string","title":"string() -> str
","text":"Joins the iterator into the str
string.
Warning The iterator must contain only items of type str
for this method to work.
This is equivalent to:
iterator.join(EMPTY_STRING)\n
Example strings = (\"x\", \"y\", \"z\")\nstring = \"xyz\"\n\niterator = iter(strings)\n\nassert iterator.string() == string\n
Returns:
Type Description str
The joined str
string.
Source code in iters/iters.py
def string(self: Iter[str]) -> str:\n \"\"\"Joins the iterator into the [`str`][str] string.\n\n Warning:\n The iterator must contain only items of type [`str`][str] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_STRING)\n ```\n\n Example:\n ```python\n strings = (\"x\", \"y\", \"z\")\n string = \"xyz\"\n\n iterator = iter(strings)\n\n assert iterator.string() == string\n ```\n\n Returns:\n The joined [`str`][str] string.\n \"\"\"\n return self.join(EMPTY_STRING)\n
"},{"location":"reference/iters/#iters.iters.Iter.bytes","title":"bytes() -> bytes
","text":"Joins the iterator into the bytes
string.
Warning The iterator must contain only items of type bytes
for this method to work.
This is equivalent to:
iterator.join(EMPTY_BYTES)\n
Returns:
Type Description bytes
The joined bytes
string.
Source code in iters/iters.py
def bytes(self: Iter[bytes]) -> bytes:\n \"\"\"Joins the iterator into the [`bytes`][bytes] string.\n\n Warning:\n The iterator must contain only items of type [`bytes`][bytes] for this method to work.\n\n This is equivalent to:\n\n ```python\n iterator.join(EMPTY_BYTES)\n ```\n\n Returns:\n The joined [`bytes`][bytes] string.\n \"\"\"\n return self.join(EMPTY_BYTES)\n
"},{"location":"reference/iters/#iters.iters.Iter.count_dict","title":"count_dict() -> Counter[Q]
","text":"Collects the iterator into the Counter[Q]
.
Warning The items of the iterator have to be hashable for this method to work.
Example bits = (0, 1, 1, 0, 1, 1, 1, 0)\n\nresult = [(1, 5), (0, 3)]\n\niterator = iter(bits)\n\nassert iterator.count_dict().most_common() == result\n
Returns:
Type Description Counter[Q]
The Counter[Q]
over the items of the iterator.
Source code in iters/iters.py
def count_dict(self: Iter[Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter].\n\n Warning:\n The items of the iterator have to be hashable for this method to work.\n\n Example:\n ```python\n bits = (0, 1, 1, 0, 1, 1, 1, 0)\n\n result = [(1, 5), (0, 3)]\n\n iterator = iter(bits)\n\n assert iterator.count_dict().most_common() == result\n ```\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the items of the iterator.\n \"\"\"\n return count_dict(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.Iter.count_dict_by","title":"count_dict_by(key: Unary[T, Q]) -> Counter[Q]
","text":"Collects the iterator into the Counter[Q]
by applying the key
function.
Example sets = [{}, {0}, {1}, {0, 1}]\n\niterator = iter(sets)\n\nresult = [(1, 2), (2, 1), (0, 1)]\n\nassert iterator.count_dict_by(len).most_common() == result\n
Parameters:
Name Type Description Default key
Unary[T, Q]
The key function.
required Returns:
Type Description Counter[Q]
The Counter[Q]
over the keys corresponding to the items of the iterator.
Source code in iters/iters.py
def count_dict_by(self, key: Unary[T, Q]) -> Counter[Q]:\n \"\"\"Collects the iterator into the [`Counter[Q]`][collections.Counter]\n by applying the `key` function.\n\n Example:\n ```python\n sets = [{}, {0}, {1}, {0, 1}]\n\n iterator = iter(sets)\n\n result = [(1, 2), (2, 1), (0, 1)]\n\n assert iterator.count_dict_by(len).most_common() == result\n ```\n\n Arguments:\n key: The key function.\n\n Returns:\n The [`Counter[Q]`][collections.Counter] over the keys\n corresponding to the items of the iterator.\n \"\"\"\n return count_dict(self.iterator, key)\n
"},{"location":"reference/iters/#iters.iters.Iter.cartesian_power","title":"cartesian_power(power: int) -> Iter[DynamicTuple[T]]
","text":"Creates an iterator over the Cartesian power of the iterator.
Warning It only makes sense to compute the Cartesian power of finite iterators.
Example bits = (0, 1)\nresult = ((0, 0), (0, 1), (1, 0), (1, 1))\n\niterator = iter(bits)\n\nassert iterator.cartesian_power(2).tuple() == result\n
Parameters:
Name Type Description Default power
int
The power to \"raise\" the iterator to.
required Returns:
Type Description Iter[DynamicTuple[T]]
An [Iter[Tuple[...]]
] over the Cartesian power of the iterator.
Source code in iters/iters.py
def cartesian_power(self, power: int) -> Iter[DynamicTuple[T]]:\n \"\"\"Creates an iterator over the\n [*Cartesian power*](https://en.wikipedia.org/wiki/Cartesian_product) of the iterator.\n\n Warning:\n It only makes sense to compute the Cartesian power of finite iterators.\n\n Example:\n ```python\n bits = (0, 1)\n result = ((0, 0), (0, 1), (1, 0), (1, 1))\n\n iterator = iter(bits)\n\n assert iterator.cartesian_power(2).tuple() == result\n ```\n\n Arguments:\n power: The power to \"raise\" the iterator to.\n\n Returns:\n An [`Iter[Tuple[...]]`] over the Cartesian power of the iterator.\n \"\"\"\n return self.create(cartesian_power(power, self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.power_set","title":"power_set() -> Iter[DynamicTuple[T]]
","text":"Computes the power set of the iterator.
The power set of $S$ contains all subsets of $S$, including the empty set $\\varnothing$ and $S$ itself. The power set is often denoted as $2^S$ since if $|S| = n$, then $|2^S| = 2^n$.
Returns:
Type Description Iter[DynamicTuple[T]]
An iterator over the power set of the iterator.
Source code in iters/iters.py
def power_set(self) -> Iter[DynamicTuple[T]]:\n \"\"\"Computes the power set of the iterator.\n\n The power set of $S$ contains all subsets of $S$, including\n the empty set $\\\\varnothing$ and $S$ itself.\n The power set is often denoted as $2^S$ since if $|S| = n$, then $|2^S| = 2^n$.\n\n Returns:\n An iterator over the power set of the iterator.\n \"\"\"\n return self.create(power_set(self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.unique","title":"unique() -> Iter[T]
","text":"Creates an iterator over the unique items in the iterator.
This function may be slower than unique_fast
in case T
is not Hashable
.
To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.
Example >>> iterator = iter.of(0, 1, 1, 0, 1, 1, 1, 0)\n>>> iterator.unique().tuple()\n(0, 1)\n
Returns:
Type Description Iter[T]
An iterator over the unique items in the iterator.
Source code in iters/iters.py
def unique(self) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator.\n\n This function may be slower than [`unique_fast`][iters.iters.Iter.unique_fast]\n in case `T` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, 1, 0, 1, 1, 1, 0)\n >>> iterator.unique().tuple()\n (0, 1)\n ```\n\n Returns:\n An iterator over the unique items in the iterator.\n \"\"\"\n return self.create(unique(self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.unique_by","title":"unique_by(key: Unary[T, V]) -> Iter[T]
","text":"Creates an iterator over the unique items in the iterator based on the given key
.
This function may be slower than unique_fast_by
in case V
is not Hashable
.
To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.
Example >>> iterator = iter.of(0, 1, -1)\n>>> iterator.unique_by(abs).tuple()\n(0, 1)\n
Parameters:
Name Type Description Default key
Unary[T, V]
The key to use in determining uniqueness.
required Returns:
Type Description Iter[T]
An iterator over the unique items in the iterator based on the given key
.
Source code in iters/iters.py
def unique_by(self, key: Unary[T, V]) -> Iter[T]:\n \"\"\"Creates an iterator over the unique items in the iterator based on the given `key`.\n\n This function may be slower than [`unique_fast_by`][iters.iters.Iter.unique_fast_by]\n in case `V` is not [`Hashable`][typing.Hashable].\n\n To be precise, this function is $O(n)$ for hashable items, and $O(n^2)$ otherwise.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1, -1)\n >>> iterator.unique_by(abs).tuple()\n (0, 1)\n ```\n\n Arguments:\n key: The key to use in determining uniqueness.\n\n Returns:\n An iterator over the unique items in the iterator based on the given `key`.\n \"\"\"\n return self.create(unique(self.iterator, key))\n
"},{"location":"reference/iters/#iters.iters.Iter.partition","title":"partition(predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]
","text":"Partitions the iterator into two iterators safely based on the given predicate
, loading all items into memory!
See predicates for more information on the predicate
argument.
Example Suppose we have the following function:
def is_positive(z: int) -> bool:\n return z > 0\n
Then
>>> iterator = iter.of(-1, 0, 1)\n>>> positive, non_positive = iterator.partition(is_positive)\n>>> positive.list()\n[1]\n>>> non_positive.list()\n[-1, 0]\n
Note This method exhausts the underlying iterator.
Parameters:
Name Type Description Default predicate
Optional[Predicate[T]]
The predicate to use in partitioning the iterator.
required Returns:
Type Description Pair[Iter[T]]
A tuple of two iterators, the former containing the items that match the predicate,
Pair[Iter[T]]
and the latter containing items that do not match the predicate.
Source code in iters/iters.py
def partition(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *safely* based on the given `predicate`,\n loading **all** items into memory!\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_positive(z: int) -> bool:\n return z > 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> positive, non_positive = iterator.partition(is_positive)\n >>> positive.list()\n [1]\n >>> non_positive.list()\n [-1, 0]\n ```\n\n Note:\n This method exhausts the underlying iterator.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n
"},{"location":"reference/iters/#iters.iters.Iter.partition_unsafe","title":"partition_unsafe(predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]
","text":"Partitions the iterator into two iterators unsafely based on the given predicate
.
See predicates for more information on the predicate
argument.
Example Suppose we have the following function:
def is_negative(z: int) -> bool:\n return z < 0\n
Then
>>> iterator = iter.of(-1, 0, 1)\n>>> negative, non_negative = iterator.partition_unsafe(is_negative)\n>>> non_negative.list()\n[0, 1]\n>>> negative.list()\n[-1]\n
Warning This method is not thread-safe!
Note This method works on the underlying iterator, so using the original iterator is not recommended after calling this method.
Parameters:
Name Type Description Default predicate
Optional[Predicate[T]]
The predicate to use in partitioning the iterator.
required Returns:
Type Description Pair[Iter[T]]
A tuple of two iterators, the former containing the items that match the predicate,
Pair[Iter[T]]
and the latter containing items that do not match the predicate.
Source code in iters/iters.py
def partition_unsafe(self, predicate: Optional[Predicate[T]]) -> Pair[Iter[T]]:\n \"\"\"Partitions the iterator into two iterators *unsafely* based on the given `predicate`.\n\n See [predicates](/predicates) for more information on the `predicate` argument.\n\n Example:\n Suppose we have the following function:\n\n ```python\n def is_negative(z: int) -> bool:\n return z < 0\n ```\n\n Then\n\n ```python\n >>> iterator = iter.of(-1, 0, 1)\n >>> negative, non_negative = iterator.partition_unsafe(is_negative)\n >>> non_negative.list()\n [0, 1]\n >>> negative.list()\n [-1]\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method works on the underlying iterator, so using the original iterator\n is not recommended after calling this method.\n\n Arguments:\n predicate: The predicate to use in partitioning the iterator.\n\n Returns:\n A tuple of two iterators, the former containing the items that match the predicate,\n and the latter containing items that do *not* match the predicate.\n \"\"\"\n true, false = partition_unsafe(predicate, self.iterator)\n\n return (self.create(true), self.create(false))\n
"},{"location":"reference/iters/#iters.iters.Iter.copy","title":"copy() -> Iter[T]
","text":"Copies the iterator safely, loading all items into memory!
Example >>> iterator = iter.of(1, 2, 3)\n>>> copy = iterator.copy()\n>>> iterator.tuple()\n(1, 2, 3)\n>>> copy.tuple()\n(1, 2, 3)\n
Note This method replaces the underlying iterator.
Returns:
Type Description Iter[T]
A copy of the iterator.
Source code in iters/iters.py
def copy(self) -> Iter[T]:\n \"\"\"Copies the iterator *safely*, loading **all** items into memory!\n\n Example:\n ```python\n >>> iterator = iter.of(1, 2, 3)\n >>> copy = iterator.copy()\n >>> iterator.tuple()\n (1, 2, 3)\n >>> copy.tuple()\n (1, 2, 3)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n
"},{"location":"reference/iters/#iters.iters.Iter.copy_unsafe","title":"copy_unsafe() -> Iter[T]
","text":"Copies the iterator unsafely.
Example >>> iterator = iter.of(13, 42, 69)\n>>> copy = iterator.copy_unsafe()\n>>> iterator.zip(copy).tuple()\n((13, 13), (42, 42), (69, 69))\n
Warning This method is not thread-safe!
Note This method replaces the underlying iterator.
Returns:
Type Description Iter[T]
A copy of the iterator.
Source code in iters/iters.py
def copy_unsafe(self) -> Iter[T]:\n \"\"\"Copies the iterator *unsafely*.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 42, 69)\n >>> copy = iterator.copy_unsafe()\n >>> iterator.zip(copy).tuple()\n ((13, 13), (42, 42), (69, 69))\n ```\n\n Warning:\n This method is not thread-safe!\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n A copy of the iterator.\n \"\"\"\n iterator, copied = copy_unsafe(self.iterator)\n\n self._replace(iterator)\n\n return self.create(copied)\n
"},{"location":"reference/iters/#iters.iters.Iter.spy","title":"spy(size: int) -> List[T]
","text":"Spies on at most size
next items of the iterator, without consuming them.
Example >>> iterator = iter.of(13, 34, 42)\n>>> iterator.spy(2)\n[13, 34]\n>>> iterator.spy(4)\n[13, 34, 42]\n>>> iterator.next()\nSome(13)\n
Note This method replaces the underlying iterator.
Parameters:
Name Type Description Default size
int
The amount of items to spy on.
required Returns:
Type Description List[T]
Up to size
next items of the iterator.
Source code in iters/iters.py
def spy(self, size: int) -> List[T]:\n \"\"\"Spies on at most `size` next items of the iterator, without consuming them.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.spy(2)\n [13, 34]\n >>> iterator.spy(4)\n [13, 34, 42]\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Arguments:\n size: The amount of items to spy on.\n\n Returns:\n Up to `size` next items of the iterator.\n \"\"\"\n result, iterator = spy(size, self.iterator)\n\n self._replace(iterator)\n\n return result\n
"},{"location":"reference/iters/#iters.iters.Iter.peek","title":"peek() -> Option[T]
","text":"Peeks at the next item in the iterator, without consuming it.
Example >>> iterator = iter.of(13, 34, 42)\n>>> iterator.peek()\nSome(13)\n>>> iterator.next()\nSome(13)\n
Note This method replaces the underlying iterator.
Returns:
Type Description Option[T]
The next item in the iterator, if one exists.
Source code in iters/iters.py
def peek(self) -> Option[T]:\n \"\"\"Peeks at the next item in the iterator, without consuming it.\n\n Example:\n ```python\n >>> iterator = iter.of(13, 34, 42)\n >>> iterator.peek()\n Some(13)\n >>> iterator.next()\n Some(13)\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n The next item in the iterator, if one exists.\n \"\"\"\n item, iterator = peek(self.iterator, marker)\n\n self._replace(iterator)\n\n return wrap_marked(item)\n
"},{"location":"reference/iters/#iters.iters.Iter.has_next","title":"has_next() -> bool
","text":"Checks if the iterator has a next item (i.e. is non-empty).
Example >>> assert iter.once(1).has_next()\n>>> assert not iter.empty().has_next()\n
Note This method replaces the underlying iterator.
Returns:
Type Description bool
Whether the iterator has a next item.
Source code in iters/iters.py
def has_next(self) -> bool:\n \"\"\"Checks if the iterator has a next item (i.e. is non-empty).\n\n Example:\n ```python\n >>> assert iter.once(1).has_next()\n >>> assert not iter.empty().has_next()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator has a next item.\n \"\"\"\n result, iterator = has_next(self.iterator)\n\n self._replace(iterator)\n\n return result\n
"},{"location":"reference/iters/#iters.iters.Iter.is_empty","title":"is_empty() -> bool
","text":"Checks if the iterator is empty.
Example >>> assert iter.empty().is_empty()\n>>> assert not iter.once(0).is_empty()\n
Note This method replaces the underlying iterator.
Returns:
Type Description bool
Whether the iterator is empty.
Source code in iters/iters.py
def is_empty(self) -> bool:\n \"\"\"Checks if the iterator is empty.\n\n Example:\n ```python\n >>> assert iter.empty().is_empty()\n >>> assert not iter.once(0).is_empty()\n ```\n\n Note:\n This method replaces the underlying iterator.\n\n Returns:\n Whether the iterator is empty.\n \"\"\"\n result, iterator = is_empty(self.iterator)\n\n self._replace(iterator)\n\n return result\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_last","title":"repeat_last() -> Iter[T]
","text":"Repeats the last item of the iterator indefinitely.
Example >>> iterator = iter.of(0, 1)\n>>> iterator.next()\nSome(0)\n>>> iterator.next()\nSome(1)\n>>> iterator.next()\nSome(1) # now repeating the last item\n
Returns:
Type Description Iter[T]
The iterator with the last item repeated indefinitely.
Source code in iters/iters.py
def repeat_last(self) -> Iter[T]:\n \"\"\"Repeats the last item of the iterator indefinitely.\n\n Example:\n ```python\n >>> iterator = iter.of(0, 1)\n >>> iterator.next()\n Some(0)\n >>> iterator.next()\n Some(1)\n >>> iterator.next()\n Some(1) # now repeating the last item\n ```\n\n Returns:\n The iterator with the last item repeated indefinitely.\n \"\"\"\n return self.create(repeat_last(self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.repeat_each","title":"repeat_each(count: int) -> Iter[T]
","text":"Repeat each item of the iterator count
times.
Example >>> iter.of(0, 1).repeat_each(2).tuple()\n(0, 0, 1, 1)\n
>>> iter.once(0).repeat_each(0).tuple()\n()\n
Parameters:
Name Type Description Default count
int
The amount of times to repeat each item.
required Returns:
Type Description Iter[T]
The iterator with each item repeated count
times.
Source code in iters/iters.py
def repeat_each(self, count: int) -> Iter[T]:\n \"\"\"Repeat each item of the iterator `count` times.\n\n Example:\n ```python\n >>> iter.of(0, 1).repeat_each(2).tuple()\n (0, 0, 1, 1)\n ```\n\n ```python\n >>> iter.once(0).repeat_each(0).tuple()\n ()\n ```\n\n Arguments:\n count: The amount of times to repeat each item.\n\n Returns:\n The iterator with each item repeated `count` times.\n \"\"\"\n return self.create(repeat_each(count, self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.inspect","title":"inspect(function: Inspect[T]) -> Iter[T]
","text":"Inspects each item of the iterator with the given function
.
Example >>> iter.of(1, 2, 3).inspect(print).consume()\n1\n2\n3\n
Parameters:
Name Type Description Default function
Inspect[T]
The inspecting function.
required Returns:
Type Description Iter[T]
The original iterator.
Source code in iters/iters.py
def inspect(self, function: Inspect[T]) -> Iter[T]:\n \"\"\"Inspects each item of the iterator with the given `function`.\n\n Example:\n ```python\n >>> iter.of(1, 2, 3).inspect(print).consume()\n 1\n 2\n 3\n ```\n\n Arguments:\n function: The inspecting function.\n\n Returns:\n The original iterator.\n \"\"\"\n return self.create(inspect(function, self.iterator))\n
"},{"location":"reference/iters/#iters.iters.Iter.into_async_iter","title":"into_async_iter() -> AsyncIter[T]
","text":"Converts an Iter[T]
into an AsyncIter[T]
.
Example >>> async_iterator = iter.of(13, 34, 42).into_async_iter()\n>>> await async_iterator.tuple()\n(13, 34, 42)\n
Returns:
Type Description AsyncIter[T]
The async iterator created from the iterator.
Source code in iters/iters.py
def into_async_iter(self) -> AsyncIter[T]:\n \"\"\"Converts an [`Iter[T]`][iters.iters.Iter] into\n an [`AsyncIter[T]`][iters.async_iters.AsyncIter].\n\n Example:\n ```python\n >>> async_iterator = iter.of(13, 34, 42).into_async_iter()\n >>> await async_iterator.tuple()\n (13, 34, 42)\n ```\n\n Returns:\n The async iterator created from the iterator.\n \"\"\"\n return async_iter(self.iterator)\n
"},{"location":"reference/iters/#iters.iters.wrap_iter","title":"wrap_iter(function: Callable[PS, Iterable[T]]) -> Callable[PS, Iter[T]]
","text":"Wraps the function
returning Iterable[T]
to return Iter[T]
.
Parameters:
Name Type Description Default function
Callable[PS, Iterable[T]]
The function to wrap.
required Returns:
Type Description Callable[PS, Iter[T]]
The wrapping function.
Source code in iters/iters.py
def wrap_iter(function: Callable[PS, Iterable[T]]) -> Callable[PS, Iter[T]]:\n \"\"\"Wraps the `function` returning [`Iterable[T]`][typing.Iterable]\n to return [`Iter[T]`][iters.iters.Iter].\n\n Arguments:\n function: The function to wrap.\n\n Returns:\n The wrapping function.\n \"\"\"\n\n @wraps(function)\n def wrap(*args: PS.args, **kwargs: PS.kwargs) -> Iter[T]:\n return iter(function(*args, **kwargs))\n\n return wrap\n
"},{"location":"reference/mappings/","title":"Mappings","text":""},{"location":"reference/mappings/#iters.mappings.merge","title":"merge(*mappings: Mapping[Any, Any], **keywords: Any) -> Dict[Any, Any]
","text":"Merges multiple mappings
and keywords
into one dictionary.
Parameters:
Name Type Description Default *mappings
Mapping[Any, Any]
Mappings to merge.
()
**keywords
Any
Keywords to add to the merged dictionary.
{}
Returns:
Type Description Dict[Any, Any]
The merged dictionary.
Source code in iters/mappings.py
def merge(*mappings: Mapping[Any, Any], **keywords: Any) -> Dict[Any, Any]:\n \"\"\"Merges multiple `mappings` and `keywords` into one dictionary.\n\n Arguments:\n *mappings: Mappings to merge.\n **keywords: Keywords to add to the merged dictionary.\n\n Returns:\n The merged dictionary.\n \"\"\"\n merged: Dict[Any, Any] = {}\n\n for mapping in mappings:\n merged.update(mapping)\n\n merged.update(keywords)\n\n return merged\n
"},{"location":"reference/ordered_set/","title":"Ordered Set","text":""},{"location":"reference/ordered_set/#iters.ordered_set.LAST","title":"LAST = ~0
module-attribute
","text":"The last index.
"},{"location":"reference/ordered_set/#iters.ordered_set.ordered_set","title":"ordered_set = OrderedSet
module-attribute
","text":"An alias of OrderedSet
.
"},{"location":"reference/ordered_set/#iters.ordered_set.ordered_set_unchecked","title":"ordered_set_unchecked = ordered_set.create_unchecked
module-attribute
","text":"An alias of ordered_set.create_unchecked
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet","title":"OrderedSet
","text":" Bases: MutableSet[Q]
, Sequence[Q]
Represents ordered sets, i.e. mutable hash sets that preserve insertion order.
The implementation is rather simple: it uses an array to store the items and a hash map to store the indices of the items in the array along with ensuring uniqueness.
The complexity of the operations assumes that hash maps have O(1)
insertion, lookup, deletion, and clearing as well as that arrays have O(1)
by-index lookup, length-checking and clearing.
Source code in iters/ordered_set.py
class OrderedSet(MutableSet[Q], Sequence[Q]):\n \"\"\"Represents ordered sets, i.e. mutable hash sets that preserve insertion order.\n\n The implementation is rather simple: it uses an *array* to store the items\n and a *hash map* to store the indices of the items in the array along with ensuring uniqueness.\n\n The complexity of the operations assumes that *hash maps*\n have `O(1)` *insertion*, *lookup*, *deletion*, and *clearing* as well\n as that *arrays* have `O(1)` *by-index lookup*, *length-checking* and *clearing*.\n \"\"\"\n\n def __init__(self, iterable: Iterable[Q] = ()) -> None:\n self._items: List[Q] = []\n self._item_to_index: Dict[Q, int] = {}\n\n self.update(iterable)\n\n @classmethod\n def create(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [0, 1, 1, 0, 1, 1, 1, 0]\n >>> order_set = ordered_set.create(array)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n return cls(iterable) # type: ignore\n\n @classmethod\n def create_unchecked(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable without checking if the items are unique.\n\n This method is useful when constructing an ordered set from an iterable that is known to\n contain unique items only.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [1, 2, 3] # we know that the items are unique\n >>> order_set = ordered_set.create_unchecked(array)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n self: OrderedSet[R] = cls.create()\n\n items = self._items\n item_to_index = self._item_to_index\n\n items.extend(iterable)\n\n for index, item in enumerate(items):\n item_to_index[item] = index\n\n return self\n\n @classmethod\n def create_union(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the union of given iterables.\n\n Arguments:\n *iterables: The iterables to create the ordered set union from.\n\n Returns:\n The ordered set union.\n \"\"\"\n return cls.create(chain(*iterables))\n\n @classmethod\n def create_intersection(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the intersection of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set intersection from.\n\n Returns:\n The ordered set intersection.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_intersection(*tail)\n\n return cls.create()\n\n @classmethod\n def create_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the orderd set difference from.\n\n Returns:\n The ordered set difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_difference(*tail)\n\n return cls.create()\n\n @classmethod\n def create_symmetric_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the symmetric difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set symmetric difference from.\n\n Returns:\n The ordered set symmetric difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_symmetric_difference(*tail)\n\n return cls.create()\n\n def __len__(self) -> int:\n return len(self._items)\n\n @overload\n def __getitem__(self, index: int) -> Q:\n ...\n\n @overload\n def __getitem__(self, index: slice) -> OrderedSet[Q]:\n ...\n\n def __getitem__(self, index: Union[int, slice]) -> Union[Q, OrderedSet[Q]]:\n if is_slice(index):\n if index == SLICE_ALL:\n return self.copy()\n\n return self.create_unchecked(self._items[index])\n\n return self._items[index] # type: ignore\n\n def copy(self) -> OrderedSet[Q]:\n \"\"\"Copies the ordered set.\n\n This is equivalent to:\n\n ```python\n order_set.create_unchecked(order_set)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set\n OrderedSet([1, 2, 3])\n >>> order_set.copy()\n OrderedSet([1, 2, 3])\n ```\n\n Returns:\n The copied ordered set.\n \"\"\"\n return self.create_unchecked(self)\n\n def __contains__(self, item: Any) -> bool:\n return item in self._item_to_index\n\n def add(self, item: Q) -> None:\n \"\"\"Adds an item to the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set\n OrderedSet()\n >>> order_set.add(0)\n >>> order_set.add(1)\n >>> order_set.add(0)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n item: The item to add.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item not in item_to_index:\n items = self._items\n\n item_to_index[item] = len(items)\n\n items.append(item)\n\n append = add\n \"\"\"An alias of [`add`][iters.ordered_set.OrderedSet.add].\"\"\"\n\n def update(self, iterable: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set with the items from an iterable.\n\n This is equivalent to:\n\n ```python\n for item in iterable:\n ordered_set.add(item)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set.update([0, 1])\n >>> order_set.update([1, 2, 3])\n >>> order_set\n OrderedSet([0, 1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to update the ordered set with.\n \"\"\"\n for item in iterable:\n self.add(item)\n\n extend = update\n \"\"\"An alias of [`update`][iters.ordered_set.OrderedSet.update].\"\"\"\n\n def index(self, item: Q, start: Optional[int] = None, stop: Optional[int] = None) -> int:\n \"\"\"Gets the index of an item in the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set.index(1)\n 0\n >>> order_set.index(5)\n Traceback (most recent call last):\n ...\n ValueError: 5 is not in the ordered set\n ```\n\n Arguments:\n item: The item to get the index of.\n start: The index to start searching from.\n stop: The index to stop searching at.\n\n Raises:\n ValueError: The item is not in the ordered set.\n\n Returns:\n The index of the item.\n \"\"\"\n index = self._item_to_index.get(item)\n error = item_not_in_ordered_set(item)\n\n if index is None:\n raise error\n\n if start is not None:\n if index < start:\n raise error\n\n if stop is not None:\n if index >= stop:\n raise error\n\n return index\n\n get_index = wrap_option(index)\n \"\"\"An alias of [`index`][iters.ordered_set.OrderedSet.index] wrapped to return\n [`Option[int]`][wraps.option.Option] instead of erroring.\n \"\"\"\n\n def count(self, item: Q) -> int:\n \"\"\"Returns `1` if an item is in the ordered set, `0` otherwise.\n\n Complexity:\n `O(1)`.\n\n Arguments:\n item: The item to count.\n\n Returns:\n `1` if the `item` is in the ordered set, `0` otherwise.\n \"\"\"\n return int(item in self._item_to_index)\n\n def pop(self, index: int = LAST) -> Q:\n \"\"\"Pops an item from the ordered set at `index`.\n\n Complexity:\n `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.pop()\n 1\n >>> order_set.pop(0)\n 0\n >>> order_set.pop()\n Traceback (most recent call last):\n ...\n IndexError: list index out of range\n ```\n\n Arguments:\n index: The index to pop the item from.\n\n Raises:\n IndexError: The index is out of range.\n\n Returns:\n The popped item.\n \"\"\"\n items = self._items\n\n item = items[index]\n\n self.discard(item)\n\n return item\n\n get_pop = wrap_option(pop)\n \"\"\"An alias of [`pop`][iters.ordered_set.OrderedSet.pop] wrapped to return\n [`Option[Q]`][wraps.option.Option] instead of erroring.\n \"\"\"\n\n def discard(self, item: Q) -> None:\n \"\"\"Discards an item from the ordered set.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the removed index must be decremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.discard(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.discard(1)\n >>> order_set.discard(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to discard.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n index = item_to_index[item]\n\n del self._items[index]\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] -= 1\n\n def remove(self, item: Q) -> None:\n \"\"\"A checked version of [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Complexity: `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.remove(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.remove(1)\n Traceback (most recent call last):\n ...\n ValueError: 1 is not in the ordered set\n >>> order_set.remove(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to remove.\n\n Raises:\n ValueError: The item is not in the ordered set.\n \"\"\"\n if item in self:\n self.discard(item)\n\n else:\n raise ValueError(ITEM_NOT_IN_ORDERED_SET.format(item))\n\n def insert(self, index: int, item: Q) -> None:\n \"\"\"Inserts an item into the ordered set at `index`.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the inserted index must be incremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 3])\n >>> order_set.insert(1, 2)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n index: The index to insert the item at.\n item: The item to insert.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n return\n\n items = self._items\n\n if index < len(items):\n items.insert(index, item)\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] += 1\n\n item_to_index[item] = index\n\n else:\n self.append(item)\n\n def clear(self) -> None:\n \"\"\"Clears the ordered set.\n\n Complexity:\n `O(1)`.\n \"\"\"\n self._items.clear()\n self._item_to_index.clear()\n\n def __iter__(self) -> Iterator[Q]:\n return iter(self._items)\n\n def __reversed__(self) -> Iterator[Q]:\n return reversed(self._items)\n\n def __repr__(self) -> str:\n name = get_type_name(self)\n\n items = self._items\n\n if not items:\n return EMPTY_REPRESENTATION.format(name)\n\n return ITEMS_REPRESENTATION.format(name, items)\n\n def __eq__(self, other: Any) -> bool:\n if is_instance(other, Iterable):\n if is_instance(other, Sequence):\n return self._items == list(other)\n\n return set(self._item_to_index) == set(other)\n\n return False\n\n def apply_union(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the union of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the union with.\n\n Returns:\n The union of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n return self.create_union(self, *iterables)\n\n return self.copy()\n\n union = mixed_method(create_union, apply_union)\n \"\"\"Mixes [`create_union`][iters.ordered_set.OrderedSet.create_union]\n and [`apply_union`][iters.ordered_set.OrderedSet.apply_union].\n \"\"\"\n\n def apply_intersection(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the intersection of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n\n Returns:\n The intersection of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n intersection = set.intersection(*map(set, iterables)) # type: ignore\n\n iterator = (item for item in self if item in intersection)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n\n intersection = mixed_method(create_intersection, apply_intersection)\n \"\"\"Mixes [`create_intersection`][iters.ordered_set.OrderedSet.create_intersection]\n and [`apply_intersection`][iters.ordered_set.OrderedSet.apply_intersection].\n \"\"\"\n\n def intersection_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the intersection of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n \"\"\"\n if iterables:\n intersection = self.intersection(*iterables)\n\n self.clear()\n\n self.update(intersection)\n\n def apply_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n\n Returns:\n The difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n union = set.union(*map(set, iterables)) # type: ignore\n iterator = (item for item in self if item not in union)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n\n difference = mixed_method(create_difference, apply_difference)\n \"\"\"Mixes [`create_difference`][iters.ordered_set.OrderedSet.create_difference]\n and [`apply_difference`][iters.ordered_set.OrderedSet.apply_difference].\n \"\"\"\n\n def difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n \"\"\"\n if iterables:\n difference = self.difference(*iterables)\n\n self.clear()\n\n self.update(difference)\n\n def single_symmetric_difference(self, other: Iterable[Q]) -> OrderedSet[Q]:\n ordered = self.create(other)\n\n return self.difference(ordered).union(ordered.difference(self))\n\n def apply_symmetric_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the symmetric difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n\n Returns:\n The symmetric difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n result = self\n\n for iterable in iterables:\n result = result.single_symmetric_difference(iterable)\n\n return result\n\n return self.copy()\n\n symmetric_difference = mixed_method(create_symmetric_difference, apply_symmetric_difference)\n \"\"\"Mixes\n [`create_symmetric_difference`][iters.ordered_set.OrderedSet.create_symmetric_difference] and\n [`apply_symmetric_difference`][iters.ordered_set.OrderedSet.apply_symmetric_difference].\n \"\"\"\n\n def symmetric_difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the symmetric difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n \"\"\"\n if iterables:\n symmetric_difference = self.symmetric_difference(*iterables)\n\n self.clear()\n\n self.update(symmetric_difference)\n\n def is_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a subset of.\n\n Returns:\n Whether the ordered set is a subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) > len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other)\n\n return len(self) <= len(other_set) and all(item in other_set for item in self)\n\n def is_strict_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict subset of.\n\n Returns:\n Whether the ordered set is a strict subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) >= len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other) # default case\n\n return len(self) < len(other_set) and all(item in other_set for item in self)\n\n def is_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a superset of.\n\n Returns:\n Whether the ordered set is a superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) >= len(other) and all(item in self for item in other)\n\n return all(item in self for item in other) # default case\n\n def is_strict_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict superset of.\n\n Returns:\n Whether the ordered set is a strict superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) > len(other) and all(item in self for item in other)\n\n array = list(other) # default case\n\n return len(self) > len(array) and all(item in self for item in array)\n\n def is_disjoint(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is disjoint with `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is disjoint with.\n\n Returns:\n Whether the ordered set is disjoint with `other`.\n \"\"\"\n return none(item in self for item in other)\n\n # I honestly hate these names ~ nekit\n\n issubset = is_subset\n issuperset = is_superset\n isdisjoint = is_disjoint\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.append","title":"append = add
class-attribute
instance-attribute
","text":"An alias of add
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.extend","title":"extend = update
class-attribute
instance-attribute
","text":"An alias of update
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.get_index","title":"get_index = wrap_option(index)
class-attribute
instance-attribute
","text":"An alias of index
wrapped to return Option[int]
instead of erroring.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.get_pop","title":"get_pop = wrap_option(pop)
class-attribute
instance-attribute
","text":"An alias of pop
wrapped to return Option[Q]
instead of erroring.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.union","title":"union = mixed_method(create_union, apply_union)
class-attribute
instance-attribute
","text":"Mixes create_union
and apply_union
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.intersection","title":"intersection = mixed_method(create_intersection, apply_intersection)
class-attribute
instance-attribute
","text":"Mixes create_intersection
and apply_intersection
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.difference","title":"difference = mixed_method(create_difference, apply_difference)
class-attribute
instance-attribute
","text":"Mixes create_difference
and apply_difference
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.symmetric_difference","title":"symmetric_difference = mixed_method(create_symmetric_difference, apply_symmetric_difference)
class-attribute
instance-attribute
","text":"Mixes create_symmetric_difference
and apply_symmetric_difference
.
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create","title":"create(iterable: Iterable[R] = ()) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set from an iterable.
Complexity O(n)
, where n
is the length of the iterable.
Example >>> array = [0, 1, 1, 0, 1, 1, 1, 0]\n>>> order_set = ordered_set.create(array)\n>>> order_set\nOrderedSet([0, 1])\n
Parameters:
Name Type Description Default iterable
Iterable[R]
The iterable to create the ordered set from.
()
Returns:
Type Description OrderedSet[R]
The created ordered set.
Source code in iters/ordered_set.py
@classmethod\ndef create(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [0, 1, 1, 0, 1, 1, 1, 0]\n >>> order_set = ordered_set.create(array)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n return cls(iterable) # type: ignore\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_unchecked","title":"create_unchecked(iterable: Iterable[R] = ()) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set from an iterable without checking if the items are unique.
This method is useful when constructing an ordered set from an iterable that is known to contain unique items only.
Complexity O(n)
, where n
is the length of the iterable.
Example >>> array = [1, 2, 3] # we know that the items are unique\n>>> order_set = ordered_set.create_unchecked(array)\n>>> order_set\nOrderedSet([1, 2, 3])\n
Parameters:
Name Type Description Default iterable
Iterable[R]
The iterable to create the ordered set from.
()
Returns:
Type Description OrderedSet[R]
The created ordered set.
Source code in iters/ordered_set.py
@classmethod\ndef create_unchecked(cls, iterable: Iterable[R] = ()) -> OrderedSet[R]:\n \"\"\"Creates an ordered set from an iterable without checking if the items are unique.\n\n This method is useful when constructing an ordered set from an iterable that is known to\n contain unique items only.\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> array = [1, 2, 3] # we know that the items are unique\n >>> order_set = ordered_set.create_unchecked(array)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to create the ordered set from.\n\n Returns:\n The created ordered set.\n \"\"\"\n self: OrderedSet[R] = cls.create()\n\n items = self._items\n item_to_index = self._item_to_index\n\n items.extend(iterable)\n\n for index, item in enumerate(items):\n item_to_index[item] = index\n\n return self\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_union","title":"create_union(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the union of given iterables.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the ordered set union from.
()
Returns:
Type Description OrderedSet[R]
The ordered set union.
Source code in iters/ordered_set.py
@classmethod\ndef create_union(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the union of given iterables.\n\n Arguments:\n *iterables: The iterables to create the ordered set union from.\n\n Returns:\n The ordered set union.\n \"\"\"\n return cls.create(chain(*iterables))\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_intersection","title":"create_intersection(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the intersection of given iterables.
The order is determined by the first iterable.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the ordered set intersection from.
()
Returns:
Type Description OrderedSet[R]
The ordered set intersection.
Source code in iters/ordered_set.py
@classmethod\ndef create_intersection(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the intersection of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set intersection from.\n\n Returns:\n The ordered set intersection.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_intersection(*tail)\n\n return cls.create()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_difference","title":"create_difference(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the difference of given iterables.
The order is determined by the first iterable.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the orderd set difference from.
()
Returns:
Type Description OrderedSet[R]
The ordered set difference.
Source code in iters/ordered_set.py
@classmethod\ndef create_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the orderd set difference from.\n\n Returns:\n The ordered set difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_difference(*tail)\n\n return cls.create()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.create_symmetric_difference","title":"create_symmetric_difference(*iterables: Iterable[R]) -> OrderedSet[R]
classmethod
","text":"Creates an ordered set that is the symmetric difference of given iterables.
The order is determined by the first iterable.
Parameters:
Name Type Description Default *iterables
Iterable[R]
The iterables to create the ordered set symmetric difference from.
()
Returns:
Type Description OrderedSet[R]
The ordered set symmetric difference.
Source code in iters/ordered_set.py
@classmethod\ndef create_symmetric_difference(cls, *iterables: Iterable[R]) -> OrderedSet[R]:\n \"\"\"Creates an ordered set that is the symmetric difference of given iterables.\n\n The order is determined by the first iterable.\n\n Arguments:\n *iterables: The iterables to create the ordered set symmetric difference from.\n\n Returns:\n The ordered set symmetric difference.\n \"\"\"\n if iterables:\n head, *tail = iterables\n\n return cls.create(head).apply_symmetric_difference(*tail)\n\n return cls.create()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.copy","title":"copy() -> OrderedSet[Q]
","text":"Copies the ordered set.
This is equivalent to:
order_set.create_unchecked(order_set)\n
Complexity O(n)
, where n
is the length of the ordered set.
Example >>> order_set = ordered_set([1, 2, 3])\n>>> order_set\nOrderedSet([1, 2, 3])\n>>> order_set.copy()\nOrderedSet([1, 2, 3])\n
Returns:
Type Description OrderedSet[Q]
The copied ordered set.
Source code in iters/ordered_set.py
def copy(self) -> OrderedSet[Q]:\n \"\"\"Copies the ordered set.\n\n This is equivalent to:\n\n ```python\n order_set.create_unchecked(order_set)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set\n OrderedSet([1, 2, 3])\n >>> order_set.copy()\n OrderedSet([1, 2, 3])\n ```\n\n Returns:\n The copied ordered set.\n \"\"\"\n return self.create_unchecked(self)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.add","title":"add(item: Q) -> None
","text":"Adds an item to the ordered set.
Complexity O(1)
.
Example >>> order_set = ordered_set()\n>>> order_set\nOrderedSet()\n>>> order_set.add(0)\n>>> order_set.add(1)\n>>> order_set.add(0)\n>>> order_set\nOrderedSet([0, 1])\n
Parameters:
Name Type Description Default item
Q
The item to add.
required Source code in iters/ordered_set.py
def add(self, item: Q) -> None:\n \"\"\"Adds an item to the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set\n OrderedSet()\n >>> order_set.add(0)\n >>> order_set.add(1)\n >>> order_set.add(0)\n >>> order_set\n OrderedSet([0, 1])\n ```\n\n Arguments:\n item: The item to add.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item not in item_to_index:\n items = self._items\n\n item_to_index[item] = len(items)\n\n items.append(item)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.update","title":"update(iterable: Iterable[Q]) -> None
","text":"Updates the ordered set with the items from an iterable.
This is equivalent to:
for item in iterable:\n ordered_set.add(item)\n
Complexity O(n)
, where n
is the length of the iterable.
Example >>> order_set = ordered_set()\n>>> order_set.update([0, 1])\n>>> order_set.update([1, 2, 3])\n>>> order_set\nOrderedSet([0, 1, 2, 3])\n
Parameters:
Name Type Description Default iterable
Iterable[Q]
The iterable to update the ordered set with.
required Source code in iters/ordered_set.py
def update(self, iterable: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set with the items from an iterable.\n\n This is equivalent to:\n\n ```python\n for item in iterable:\n ordered_set.add(item)\n ```\n\n Complexity:\n `O(n)`, where `n` is the length of the iterable.\n\n Example:\n ```python\n >>> order_set = ordered_set()\n >>> order_set.update([0, 1])\n >>> order_set.update([1, 2, 3])\n >>> order_set\n OrderedSet([0, 1, 2, 3])\n ```\n\n Arguments:\n iterable: The iterable to update the ordered set with.\n \"\"\"\n for item in iterable:\n self.add(item)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.index","title":"index(item: Q, start: Optional[int] = None, stop: Optional[int] = None) -> int
","text":"Gets the index of an item in the ordered set.
Complexity O(1)
.
Example >>> order_set = ordered_set([1, 2, 3])\n>>> order_set.index(1)\n0\n>>> order_set.index(5)\nTraceback (most recent call last):\n ...\nValueError: 5 is not in the ordered set\n
Parameters:
Name Type Description Default item
Q
The item to get the index of.
required start
Optional[int]
The index to start searching from.
None
stop
Optional[int]
The index to stop searching at.
None
Raises:
Type Description ValueError
The item is not in the ordered set.
Returns:
Type Description int
The index of the item.
Source code in iters/ordered_set.py
def index(self, item: Q, start: Optional[int] = None, stop: Optional[int] = None) -> int:\n \"\"\"Gets the index of an item in the ordered set.\n\n Complexity:\n `O(1)`.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 2, 3])\n >>> order_set.index(1)\n 0\n >>> order_set.index(5)\n Traceback (most recent call last):\n ...\n ValueError: 5 is not in the ordered set\n ```\n\n Arguments:\n item: The item to get the index of.\n start: The index to start searching from.\n stop: The index to stop searching at.\n\n Raises:\n ValueError: The item is not in the ordered set.\n\n Returns:\n The index of the item.\n \"\"\"\n index = self._item_to_index.get(item)\n error = item_not_in_ordered_set(item)\n\n if index is None:\n raise error\n\n if start is not None:\n if index < start:\n raise error\n\n if stop is not None:\n if index >= stop:\n raise error\n\n return index\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.count","title":"count(item: Q) -> int
","text":"Returns 1
if an item is in the ordered set, 0
otherwise.
Complexity O(1)
.
Parameters:
Name Type Description Default item
Q
The item to count.
required Returns:
Type Description int
1
if the item
is in the ordered set, 0
otherwise.
Source code in iters/ordered_set.py
def count(self, item: Q) -> int:\n \"\"\"Returns `1` if an item is in the ordered set, `0` otherwise.\n\n Complexity:\n `O(1)`.\n\n Arguments:\n item: The item to count.\n\n Returns:\n `1` if the `item` is in the ordered set, `0` otherwise.\n \"\"\"\n return int(item in self._item_to_index)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.pop","title":"pop(index: int = LAST) -> Q
","text":"Pops an item from the ordered set at index
.
Complexity O(n)
, see discard
.
Example >>> order_set = ordered_set([0, 1])\n>>> order_set.pop()\n1\n>>> order_set.pop(0)\n0\n>>> order_set.pop()\nTraceback (most recent call last):\n ...\nIndexError: list index out of range\n
Parameters:
Name Type Description Default index
int
The index to pop the item from.
LAST
Raises:
Type Description IndexError
The index is out of range.
Returns:
Type Description Q
The popped item.
Source code in iters/ordered_set.py
def pop(self, index: int = LAST) -> Q:\n \"\"\"Pops an item from the ordered set at `index`.\n\n Complexity:\n `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.pop()\n 1\n >>> order_set.pop(0)\n 0\n >>> order_set.pop()\n Traceback (most recent call last):\n ...\n IndexError: list index out of range\n ```\n\n Arguments:\n index: The index to pop the item from.\n\n Raises:\n IndexError: The index is out of range.\n\n Returns:\n The popped item.\n \"\"\"\n items = self._items\n\n item = items[index]\n\n self.discard(item)\n\n return item\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.discard","title":"discard(item: Q) -> None
","text":"Discards an item from the ordered set.
Complexity O(n)
, where n
is the length of the ordered set. This is because all indices after the removed index must be decremented.
Example >>> order_set = ordered_set([0, 1])\n>>> order_set.discard(1)\n>>> order_set\nOrderedSet([0])\n>>> order_set.discard(1)\n>>> order_set.discard(0)\n>>> order_set\nOrderedSet()\n
Parameters:
Name Type Description Default item
Q
The item to discard.
required Source code in iters/ordered_set.py
def discard(self, item: Q) -> None:\n \"\"\"Discards an item from the ordered set.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the removed index must be decremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.discard(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.discard(1)\n >>> order_set.discard(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to discard.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n index = item_to_index[item]\n\n del self._items[index]\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] -= 1\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.remove","title":"remove(item: Q) -> None
","text":"A checked version of discard
.
Complexity: O(n)
, see discard
.
Example >>> order_set = ordered_set([0, 1])\n>>> order_set.remove(1)\n>>> order_set\nOrderedSet([0])\n>>> order_set.remove(1)\nTraceback (most recent call last):\n ...\nValueError: 1 is not in the ordered set\n>>> order_set.remove(0)\n>>> order_set\nOrderedSet()\n
Parameters:
Name Type Description Default item
Q
The item to remove.
required Raises:
Type Description ValueError
The item is not in the ordered set.
Source code in iters/ordered_set.py
def remove(self, item: Q) -> None:\n \"\"\"A checked version of [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Complexity: `O(n)`, see [`discard`][iters.ordered_set.OrderedSet.discard].\n\n Example:\n ```python\n >>> order_set = ordered_set([0, 1])\n >>> order_set.remove(1)\n >>> order_set\n OrderedSet([0])\n >>> order_set.remove(1)\n Traceback (most recent call last):\n ...\n ValueError: 1 is not in the ordered set\n >>> order_set.remove(0)\n >>> order_set\n OrderedSet()\n ```\n\n Arguments:\n item: The item to remove.\n\n Raises:\n ValueError: The item is not in the ordered set.\n \"\"\"\n if item in self:\n self.discard(item)\n\n else:\n raise ValueError(ITEM_NOT_IN_ORDERED_SET.format(item))\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.insert","title":"insert(index: int, item: Q) -> None
","text":"Inserts an item into the ordered set at index
.
Complexity O(n)
, where n
is the length of the ordered set. This is because all indices after the inserted index must be incremented.
Example >>> order_set = ordered_set([1, 3])\n>>> order_set.insert(1, 2)\n>>> order_set\nOrderedSet([1, 2, 3])\n
Parameters:
Name Type Description Default index
int
The index to insert the item at.
required item
Q
The item to insert.
required Source code in iters/ordered_set.py
def insert(self, index: int, item: Q) -> None:\n \"\"\"Inserts an item into the ordered set at `index`.\n\n Complexity:\n `O(n)`, where `n` is the length of the ordered set.\n This is because all indices after the inserted index must be incremented.\n\n Example:\n ```python\n >>> order_set = ordered_set([1, 3])\n >>> order_set.insert(1, 2)\n >>> order_set\n OrderedSet([1, 2, 3])\n ```\n\n Arguments:\n index: The index to insert the item at.\n item: The item to insert.\n \"\"\"\n item_to_index = self._item_to_index\n\n if item in item_to_index:\n return\n\n items = self._items\n\n if index < len(items):\n items.insert(index, item)\n\n for item_in, index_in in item_to_index.items():\n if index_in >= index:\n item_to_index[item_in] += 1\n\n item_to_index[item] = index\n\n else:\n self.append(item)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.clear","title":"clear() -> None
","text":"Clears the ordered set.
Complexity O(1)
.
Source code in iters/ordered_set.py
def clear(self) -> None:\n \"\"\"Clears the ordered set.\n\n Complexity:\n `O(1)`.\n \"\"\"\n self._items.clear()\n self._item_to_index.clear()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_union","title":"apply_union(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the union of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the union with.
()
Returns:
Type Description OrderedSet[Q]
The union of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_union(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the union of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the union with.\n\n Returns:\n The union of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n return self.create_union(self, *iterables)\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_intersection","title":"apply_intersection(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the intersection of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the intersection with.
()
Returns:
Type Description OrderedSet[Q]
The intersection of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_intersection(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the intersection of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n\n Returns:\n The intersection of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n intersection = set.intersection(*map(set, iterables)) # type: ignore\n\n iterator = (item for item in self if item in intersection)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.intersection_update","title":"intersection_update(*iterables: Iterable[Q]) -> None
","text":"Updates the ordered set to be the intersection of itself and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the intersection with.
()
Source code in iters/ordered_set.py
def intersection_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the intersection of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the intersection with.\n \"\"\"\n if iterables:\n intersection = self.intersection(*iterables)\n\n self.clear()\n\n self.update(intersection)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_difference","title":"apply_difference(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the difference of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the difference with.
()
Returns:
Type Description OrderedSet[Q]
The difference of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n\n Returns:\n The difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n union = set.union(*map(set, iterables)) # type: ignore\n iterator = (item for item in self if item not in union)\n\n return self.create_unchecked(iterator)\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.difference_update","title":"difference_update(*iterables: Iterable[Q]) -> None
","text":"Updates the ordered set to be the difference of itself and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the difference with.
()
Source code in iters/ordered_set.py
def difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the difference with.\n \"\"\"\n if iterables:\n difference = self.difference(*iterables)\n\n self.clear()\n\n self.update(difference)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.apply_symmetric_difference","title":"apply_symmetric_difference(*iterables: Iterable[Q]) -> OrderedSet[Q]
","text":"Returns the symmetric difference of the ordered set and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the symmetric difference with.
()
Returns:
Type Description OrderedSet[Q]
The symmetric difference of the ordered set and iterables
.
Source code in iters/ordered_set.py
def apply_symmetric_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:\n \"\"\"Returns the symmetric difference of the ordered set and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n\n Returns:\n The symmetric difference of the ordered set and `iterables`.\n \"\"\"\n if iterables:\n result = self\n\n for iterable in iterables:\n result = result.single_symmetric_difference(iterable)\n\n return result\n\n return self.copy()\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.symmetric_difference_update","title":"symmetric_difference_update(*iterables: Iterable[Q]) -> None
","text":"Updates the ordered set to be the symmetric difference of itself and iterables
.
Parameters:
Name Type Description Default *iterables
Iterable[Q]
The iterables to find the symmetric difference with.
()
Source code in iters/ordered_set.py
def symmetric_difference_update(self, *iterables: Iterable[Q]) -> None:\n \"\"\"Updates the ordered set to be the symmetric difference of itself and `iterables`.\n\n Arguments:\n *iterables: The iterables to find the symmetric difference with.\n \"\"\"\n if iterables:\n symmetric_difference = self.symmetric_difference(*iterables)\n\n self.clear()\n\n self.update(symmetric_difference)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_subset","title":"is_subset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a subset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a subset of.
required Returns:
Type Description bool
Whether the ordered set is a subset of other
.
Source code in iters/ordered_set.py
def is_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a subset of.\n\n Returns:\n Whether the ordered set is a subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) > len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other)\n\n return len(self) <= len(other_set) and all(item in other_set for item in self)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_strict_subset","title":"is_strict_subset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a strict subset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a strict subset of.
required Returns:
Type Description bool
Whether the ordered set is a strict subset of other
.
Source code in iters/ordered_set.py
def is_strict_subset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict subset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict subset of.\n\n Returns:\n Whether the ordered set is a strict subset of `other`.\n \"\"\"\n if is_instance(other, Sized): # cover obvious cases\n if len(self) >= len(other):\n return False\n\n if is_instance(other, AnySet): # speedup for sets\n return all(item in other for item in self)\n\n other_set = set(other) # default case\n\n return len(self) < len(other_set) and all(item in other_set for item in self)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_superset","title":"is_superset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a superset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a superset of.
required Returns:
Type Description bool
Whether the ordered set is a superset of other
.
Source code in iters/ordered_set.py
def is_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a superset of.\n\n Returns:\n Whether the ordered set is a superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) >= len(other) and all(item in self for item in other)\n\n return all(item in self for item in other) # default case\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_strict_superset","title":"is_strict_superset(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is a strict superset of other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is a strict superset of.
required Returns:
Type Description bool
Whether the ordered set is a strict superset of other
.
Source code in iters/ordered_set.py
def is_strict_superset(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is a strict superset of `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is a strict superset of.\n\n Returns:\n Whether the ordered set is a strict superset of `other`.\n \"\"\"\n if is_instance(other, Sized): # speedup for sized iterables\n return len(self) > len(other) and all(item in self for item in other)\n\n array = list(other) # default case\n\n return len(self) > len(array) and all(item in self for item in array)\n
"},{"location":"reference/ordered_set/#iters.ordered_set.OrderedSet.is_disjoint","title":"is_disjoint(other: Iterable[Q]) -> bool
","text":"Checks if the ordered set is disjoint with other
.
Parameters:
Name Type Description Default other
Iterable[Q]
The iterable to check if the ordered set is disjoint with.
required Returns:
Type Description bool
Whether the ordered set is disjoint with other
.
Source code in iters/ordered_set.py
def is_disjoint(self, other: Iterable[Q]) -> bool:\n \"\"\"Checks if the ordered set is disjoint with `other`.\n\n Arguments:\n other: The iterable to check if the ordered set is disjoint with.\n\n Returns:\n Whether the ordered set is disjoint with `other`.\n \"\"\"\n return none(item in self for item in other)\n
"},{"location":"reference/types/","title":"Types","text":""},{"location":"reference/types/#iters.types.no_default","title":"no_default = NoDefault()
module-attribute
","text":"The instance of NoDefault
.
"},{"location":"reference/types/#iters.types.marker","title":"marker = Marker()
module-attribute
","text":"The instance of Marker
.
"},{"location":"reference/types/#iters.types.NoDefault","title":"NoDefault
","text":" Bases: Singleton
Represents the absence of default values.
Source code in iters/types.py
class NoDefault(Singleton):\n \"\"\"Represents the absence of default values.\"\"\"\n
"},{"location":"reference/types/#iters.types.Marker","title":"Marker
","text":" Bases: Singleton
Represents markers used for various checks.
Source code in iters/types.py
class Marker(Singleton):\n \"\"\"Represents markers used for various checks.\"\"\"\n
"},{"location":"reference/types/#iters.types.is_no_default","title":"is_no_default(item: Any) -> TypeGuard[NoDefault]
","text":"Checks if the item
is NoDefault
.
Returns:
Type Description TypeGuard[NoDefault]
Whether the item
is NoDefault
.
Source code in iters/types.py
def is_no_default(item: Any) -> TypeGuard[NoDefault]:\n \"\"\"Checks if the `item` is [`NoDefault`][iters.types.NoDefault].\n\n Returns:\n Whether the `item` is [`NoDefault`][iters.types.NoDefault].\n \"\"\"\n return item is no_default\n
"},{"location":"reference/types/#iters.types.is_not_no_default","title":"is_not_no_default(item: NoDefaultOr[T]) -> TypeGuard[T]
","text":"Checks if the item
is not NoDefault
.
Returns:
Type Description TypeGuard[T]
Whether the item
is not NoDefault
.
Source code in iters/types.py
def is_not_no_default(item: NoDefaultOr[T]) -> TypeGuard[T]:\n \"\"\"Checks if the `item` is not [`NoDefault`][iters.types.NoDefault].\n\n Returns:\n Whether the `item` is not [`NoDefault`][iters.types.NoDefault].\n \"\"\"\n return item is not no_default\n
"},{"location":"reference/types/#iters.types.is_marker","title":"is_marker(item: Any) -> TypeGuard[Marker]
","text":"Checks if the item
is Marker
.
Returns:
Type Description TypeGuard[Marker]
Whether the item
is Marker
.
Source code in iters/types.py
def is_marker(item: Any) -> TypeGuard[Marker]:\n \"\"\"Checks if the `item` is [`Marker`][iters.types.Marker].\n\n Returns:\n Whether the `item` is [`Marker`][iters.types.Marker].\n \"\"\"\n return item is marker\n
"},{"location":"reference/types/#iters.types.is_not_marker","title":"is_not_marker(item: MarkerOr[T]) -> TypeGuard[T]
","text":"Checks if the item
is not Marker
.
Returns:
Type Description TypeGuard[T]
Whether the item
is not Marker
.
Source code in iters/types.py
def is_not_marker(item: MarkerOr[T]) -> TypeGuard[T]:\n \"\"\"Checks if the `item` is not [`Marker`][iters.types.Marker].\n\n Returns:\n Whether the `item` is not [`Marker`][iters.types.Marker].\n \"\"\"\n return item is not marker\n
"},{"location":"reference/typing/","title":"Typing","text":""},{"location":"reference/typing/#iters.typing.Sum","title":"Sum
","text":" Bases: Protocol
Represents types for which adding self: S
to other: S
returns S
.
Source code in iters/typing.py
@runtime_checkable\nclass Sum(Protocol):\n \"\"\"Represents types for which adding `self: S` to `other: S` returns `S`.\"\"\"\n\n @required\n def __add__(self: S, __other: S) -> S:\n raise NotImplementedError\n
"},{"location":"reference/typing/#iters.typing.Product","title":"Product
","text":" Bases: Protocol
Represents types for which multiplying self: P
with other: P
returns P
.
Source code in iters/typing.py
@runtime_checkable\nclass Product(Protocol):\n \"\"\"Represents types for which multiplying `self: P` with `other: P` returns `P`.\"\"\"\n\n @required\n def __mul__(self: P, __other: P) -> P:\n raise NotImplementedError\n
"},{"location":"reference/utils/","title":"Utilities","text":""}]}
\ No newline at end of file
diff --git a/sitemap.xml.gz b/sitemap.xml.gz
index e4bc9e9..5785bf1 100644
Binary files a/sitemap.xml.gz and b/sitemap.xml.gz differ