Skip to main content

lionfuncs

License: MIT

A Python utility library for robust asynchronous programming, file system operations, and network interactions.

Overview

lionfuncs provides a core set of reusable utilities designed to simplify common programming tasks with a focus on reliability and performance. It offers a comprehensive suite of tools for asynchronous operations, file system interactions, network calls, concurrency management, error handling, and general utilities.

Key Features

  • Async Utilities: Powerful tools like alcall and bcall for concurrent execution with fine-grained control
  • Concurrency Management: Primitives such as BoundedQueue and WorkQueue for managing concurrent workloads
  • File System Operations: Utilities for reading, writing, and processing files with both sync and async APIs
  • Network Client: Resilient HTTP client with built-in circuit breaker, retry, and rate limiting capabilities
  • Error Handling: Standardized error types and handling mechanisms
  • Media Processing: Optional utilities for working with images and PDFs

Installation

Basic Installation

pip install lionfuncs

Installation with Media Utilities

To use the media utilities (e.g., pdf_to_images), install with the media extra:

pip install lionfuncs[media]

Quick Start

Asynchronous Operations

import asyncio
from lionfuncs.async_utils import alcall

async def process_item(item):
    await asyncio.sleep(0.1)  # Simulate some async work
    return item * 2

async def main():
    items = [1, 2, 3, 4, 5]
    # Process all items concurrently with a max concurrency of 3
    results = await alcall(items, process_item, max_concurrent=3)
    print(results)  # [2, 4, 6, 8, 10]

asyncio.run(main())

File System Operations

import asyncio
from lionfuncs.file_system import read_file, save_to_file

async def main():
    # Read a file
    content = await read_file("example.txt")

    # Process the content
    processed_content = content.upper()

    # Save the processed content
    await save_to_file(processed_content, "output", "example_processed.txt")

asyncio.run(main())

Network Operations

import asyncio
from lionfuncs.network import AsyncAPIClient, circuit_breaker, with_retry

# Apply resilience patterns with decorators
@circuit_breaker(failure_threshold=3, recovery_time=10.0)
@with_retry(max_retries=3, base_delay=1.0, backoff_factor=2.0)
async def fetch_data(client, endpoint):
    return await client.request("GET", endpoint)

async def main():
    async with AsyncAPIClient(base_url="https://api.example.com") as client:
        data = await fetch_data(client, "/data")
        print(data)

asyncio.run(main())

Documentation

For comprehensive documentation, including detailed API references and usage guides, visit:

Contributing

We welcome contributions to lionfuncs! Please see our Contribution Guidelines for details on how to get started, coding standards, and the pull request process.

License

lionfuncs is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for lionfuncs 3.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 lionfuncs 3.2.0
File Size Uploaded Provenance
lionfuncs-3.2.0.tar.gz 383.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 452.2 kB

Release files / lionfuncs-3.2.0.tar.gz

Download URL lionfuncs-3.2.0.tar.gz
Size 383.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0b314f217c873cf21634dcb828fdfb9043dbfa9f76686cb975be2648e3c02f9d
BLAKE2b-256 checksum
How to use checksums
ccd295a92f1c93c9519b055e554ee2da9817316e892afb9f29ae08c976dae927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Release files / lionfuncs-3.2.0-py3-none-any.whl

Download URL lionfuncs-3.2.0-py3-none-any.whl
Size 69.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9239cd23a3bbf0ece2d6dcd2059facf060c8d898c91b39d5847024397e7f38b
BLAKE2b-256 checksum
How to use checksums
2f095a5a41e145c1450307ff45efa5183e3cfcad344a4dd26490ce58783f1fc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Security for lionfuncs 3.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

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