Skip to main content

memiter

memiter is a Python library that enhances the functionality of generators, making pagination and data access simpler and more intuitive.

It allows users to limit the number of elements generated, set the current page for pagination, and access the data that has been generated as many times as needed.

Additionally, it keeps the original generator, allowing the data to be generated again in a different configuration.

Features

  • Pagination: Easily paginate through large datasets by setting limits and pages.
  • Data Access: Access the generated data multiple times without re-running the generator.
  • Flexibility: Keep the original generator for re-generation of data with different parameters.

Installation

Requirements:

  • Python 3.8+

To install memiter, simply use pip:

pip install memiter

Quick Start

Here's a quick example to get you started:

from memiter import memiter

# Create a memiter instance from a range generator
my_gen = memiter(range(100)).limit(5).page(2)

# Generate and access the data
print(list(my_gen))
# Output: [5, 6, 7, 8, 9]

# Access the data that has been generated
print(my_gen.data)
# Output: [5, 6, 7, 8, 9]

Usage

Creating a Memiter Instance

You can create a memiter instance from any iterable:

from memiter import memiter

my_gen = memiter(range(100))

Hurray! Your memiter instance is now ready to be used!

By default, the memiter instance will generate all the data from the original generator.

But if you want your can enhance the functionality of your generator by using the following methods:

Pagination

Limit the number of elements and set the current page:

  • limit - Set the number of elements to generate.
  • page - Set the current page for pagination.
my_gen.limit(5).page(2)

Iterating Over Data

like any other generator, you can iterate over the data generated by the memiter instance:

for data in my_gen:
    print(data)

Accessing Data

memiter allows you to access the data that has been generated multiple times without re-running the generator.

You can access the data that has been generated using the data attribute:

print(my_gen.data)

License

memiter is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for memiter 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memiter 0.2.0
File Size Uploaded
memiter-0.2.0.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for memiter 0.2.0
File Interpreter ABI Platform
memiter-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / memiter-0.2.0.tar.gz

Download URL memiter-0.2.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9c02682a29b32c5553e397101698c3d60c0265a568e8a1cb0366ff0a9d5f32b9
BLAKE2b-256 checksum
How to use checksums
c5ce1303a9578fdc12e2a63a9f2b3bd2eb8bfb15f13caba607b7e6c761c35031
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/5.15.146.1-microsoft-standard-WSL2

Release files / memiter-0.2.0-py3-none-any.whl

Download URL memiter-0.2.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02aeac8de0cc6a2d7459dcc1150e3dad949b6e43050947f17aca21e76ce6b102
BLAKE2b-256 checksum
How to use checksums
2bfe669e8a6a0eea1e5d953b81b36ca0f62311315a9f156853b9d6f0c6e93d7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/5.15.146.1-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page