latenpy


Namelatenpy JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryA package for lazy evaluation and caching to optimize scientific analysis workflows.
upload_time2025-01-05 17:52:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords caching computation dependency evaluation lazy tracking
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LatenPy

LatenPy is a Python package that provides elegant lazy evaluation and computation caching with automatic dependency tracking. It's designed to help you optimize complex computational workflows by deferring expensive calculations until they're needed and caching results efficiently.

[![PyPI version](https://badge.fury.io/py/latenpy.svg)](https://badge.fury.io/py/latenpy)
[![Documentation Status](https://readthedocs.org/projects/latenpy/badge/?version=latest)](https://latenpy.readthedocs.io/en/latest/?badge=latest)
[![Python Versions](https://img.shields.io/pypi/pyversions/latenpy.svg)](https://pypi.org/project/latenpy/)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Tests](https://github.com/landoskape/latenpy/actions/workflows/tests.yml/badge.svg)](https://github.com/landoskape/latenpy/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/landoskape/latenpy/branch/main/graph/badge.svg)](https://codecov.io/gh/landoskape/latenpy)

[Full Documentation](https://latenpy.readthedocs.io/) | [GitHub](https://github.com/landoskape/latenpy) | [PyPI](https://pypi.org/project/latenpy/)


## Features

- 🦥 **Lazy Evaluation**: Defer computations until their results are actually needed
- 📦 **Automatic Caching**: Cache computation results for reuse
- 🔄 **Dependency Tracking**: Automatically track and manage computational dependencies
- 📊 **Visualization**: Visualize computation graphs to understand dependencies
- 🎯 **Smart Recomputation**: Only recompute results when dependencies change
- 📝 **Rich Statistics**: Track computation and access patterns

## Installation
```bash
pip install latenpy
```

## Documentation

Comprehensive documentation is available at [Read the Docs](https://latenpy.readthedocs.io/), including:

- **Quick Start Guide**: Get up and running with basic examples
- **Core Concepts**: Learn about Latent Objects, Dependency Tracking, and Caching
- **API Reference**: Detailed documentation of all classes and functions
- **Advanced Usage**: Topics like cache management, dependency graph analysis, and performance optimization
- **Examples**: Real-world examples including scientific computing and data processing pipelines

To build the documentation locally:

```bash
cd docs
make html
```

The built documentation will be available in `docs/build/html/index.html`.

## Quick Start

Here's a simple example showing how to use LatenPy:

```python
from latenpy import latent

@latent
def expensive_calculation(x):
    return x ** 2

@latent
def complex_operation(a, b):
    return a + b

# Create lazy computations
calc1 = expensive_calculation(5)
calc2 = expensive_calculation(10)
result = complex_operation(calc1, calc2)

# Nothing is computed yet!
# Computation happens only when we call .compute()
final_result = result.compute()  # 125
```

## Advanced Features

### Dependency Visualization

LatenPy can visualize your computation graph:

```python
from latenpy import visualize

# Visualize the computation graph
G = result.get_dependency_graph()
visualize(G)
```

### Computation Statistics

Track detailed statistics about your computations:

```python
# Get computation statistics
stats = result.latent_data.stats
print(stats)
# {
#     "computed": True,
#     "compute_count": 1,
#     "access_count": 1,
#     "last_compute": "2024-03-21 10:30:00",
#     "last_access": "2024-03-21 10:30:00",
#     "age": 42.0
# }
```

### Nested Computations

LatenPy handles nested data structures automatically:

```python
@latent
def process_list(items):
    return [x * 2 for x in items]

@latent
def sum_results(processed):
    return sum(processed)

# Works with nested structures
data = process_list([1, 2, 3])
total = sum_results(data)
result = total.compute()  # 12
```

## Key Concepts

- **Latent Objects**: Wrap functions and their arguments for lazy evaluation
- **Dependency Graph**: Automatically tracks relationships between computations
- **Smart Caching**: Results are cached and only recomputed when necessary
- **Computation Control**: Fine-grained control over when and how computations occur

## Use Cases

- 🔬 Scientific Computing: Manage complex computational pipelines
- 📊 Data Analysis: Optimize data processing workflows
- 🔄 Parameter Studies: Flexibly modify inputs and track changes in results

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "latenpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "caching, computation, dependency, evaluation, lazy, tracking",
    "author": null,
    "author_email": "Andrew Landau <andrew+tyler+landau+getridofthisanddtheplusses@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2b/4e/6f8cbca4b1289fe90fa49bf0d10d70c7502f4372ee64a389332e20d4572f/latenpy-0.0.2.tar.gz",
    "platform": null,
    "description": "# LatenPy\n\nLatenPy is a Python package that provides elegant lazy evaluation and computation caching with automatic dependency tracking. It's designed to help you optimize complex computational workflows by deferring expensive calculations until they're needed and caching results efficiently.\n\n[![PyPI version](https://badge.fury.io/py/latenpy.svg)](https://badge.fury.io/py/latenpy)\n[![Documentation Status](https://readthedocs.org/projects/latenpy/badge/?version=latest)](https://latenpy.readthedocs.io/en/latest/?badge=latest)\n[![Python Versions](https://img.shields.io/pypi/pyversions/latenpy.svg)](https://pypi.org/project/latenpy/)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Tests](https://github.com/landoskape/latenpy/actions/workflows/tests.yml/badge.svg)](https://github.com/landoskape/latenpy/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/landoskape/latenpy/branch/main/graph/badge.svg)](https://codecov.io/gh/landoskape/latenpy)\n\n[Full Documentation](https://latenpy.readthedocs.io/) | [GitHub](https://github.com/landoskape/latenpy) | [PyPI](https://pypi.org/project/latenpy/)\n\n\n## Features\n\n- \ud83e\udda5 **Lazy Evaluation**: Defer computations until their results are actually needed\n- \ud83d\udce6 **Automatic Caching**: Cache computation results for reuse\n- \ud83d\udd04 **Dependency Tracking**: Automatically track and manage computational dependencies\n- \ud83d\udcca **Visualization**: Visualize computation graphs to understand dependencies\n- \ud83c\udfaf **Smart Recomputation**: Only recompute results when dependencies change\n- \ud83d\udcdd **Rich Statistics**: Track computation and access patterns\n\n## Installation\n```bash\npip install latenpy\n```\n\n## Documentation\n\nComprehensive documentation is available at [Read the Docs](https://latenpy.readthedocs.io/), including:\n\n- **Quick Start Guide**: Get up and running with basic examples\n- **Core Concepts**: Learn about Latent Objects, Dependency Tracking, and Caching\n- **API Reference**: Detailed documentation of all classes and functions\n- **Advanced Usage**: Topics like cache management, dependency graph analysis, and performance optimization\n- **Examples**: Real-world examples including scientific computing and data processing pipelines\n\nTo build the documentation locally:\n\n```bash\ncd docs\nmake html\n```\n\nThe built documentation will be available in `docs/build/html/index.html`.\n\n## Quick Start\n\nHere's a simple example showing how to use LatenPy:\n\n```python\nfrom latenpy import latent\n\n@latent\ndef expensive_calculation(x):\n    return x ** 2\n\n@latent\ndef complex_operation(a, b):\n    return a + b\n\n# Create lazy computations\ncalc1 = expensive_calculation(5)\ncalc2 = expensive_calculation(10)\nresult = complex_operation(calc1, calc2)\n\n# Nothing is computed yet!\n# Computation happens only when we call .compute()\nfinal_result = result.compute()  # 125\n```\n\n## Advanced Features\n\n### Dependency Visualization\n\nLatenPy can visualize your computation graph:\n\n```python\nfrom latenpy import visualize\n\n# Visualize the computation graph\nG = result.get_dependency_graph()\nvisualize(G)\n```\n\n### Computation Statistics\n\nTrack detailed statistics about your computations:\n\n```python\n# Get computation statistics\nstats = result.latent_data.stats\nprint(stats)\n# {\n#     \"computed\": True,\n#     \"compute_count\": 1,\n#     \"access_count\": 1,\n#     \"last_compute\": \"2024-03-21 10:30:00\",\n#     \"last_access\": \"2024-03-21 10:30:00\",\n#     \"age\": 42.0\n# }\n```\n\n### Nested Computations\n\nLatenPy handles nested data structures automatically:\n\n```python\n@latent\ndef process_list(items):\n    return [x * 2 for x in items]\n\n@latent\ndef sum_results(processed):\n    return sum(processed)\n\n# Works with nested structures\ndata = process_list([1, 2, 3])\ntotal = sum_results(data)\nresult = total.compute()  # 12\n```\n\n## Key Concepts\n\n- **Latent Objects**: Wrap functions and their arguments for lazy evaluation\n- **Dependency Graph**: Automatically tracks relationships between computations\n- **Smart Caching**: Results are cached and only recomputed when necessary\n- **Computation Control**: Fine-grained control over when and how computations occur\n\n## Use Cases\n\n- \ud83d\udd2c Scientific Computing: Manage complex computational pipelines\n- \ud83d\udcca Data Analysis: Optimize data processing workflows\n- \ud83d\udd04 Parameter Studies: Flexibly modify inputs and track changes in results\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.",
    "bugtrack_url": null,
    "license": null,
    "summary": "A package for lazy evaluation and caching to optimize scientific analysis workflows.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/landoskape/latenpy"
    },
    "split_keywords": [
        "caching",
        " computation",
        " dependency",
        " evaluation",
        " lazy",
        " tracking"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e60336dd1ef7b14f793d225fd7a1cf418d2d9647377973facd129a6878d510ed",
                "md5": "3b68da65628974d37c517abad8d90191",
                "sha256": "59d76ebb0d618b16e4e807a8e554d427e4dbc74ef46c6ad113294de1cceaa3d0"
            },
            "downloads": -1,
            "filename": "latenpy-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3b68da65628974d37c517abad8d90191",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 15327,
            "upload_time": "2025-01-05T17:52:27",
            "upload_time_iso_8601": "2025-01-05T17:52:27.092422Z",
            "url": "https://files.pythonhosted.org/packages/e6/03/36dd1ef7b14f793d225fd7a1cf418d2d9647377973facd129a6878d510ed/latenpy-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b4e6f8cbca4b1289fe90fa49bf0d10d70c7502f4372ee64a389332e20d4572f",
                "md5": "1ef062be0eda9f829eaf1d326e5386b5",
                "sha256": "d4ff7ff70d42b9b4c944c5e80bb94c8d5fbc4d42d363c0e459b43f1d6aa90578"
            },
            "downloads": -1,
            "filename": "latenpy-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1ef062be0eda9f829eaf1d326e5386b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16451,
            "upload_time": "2025-01-05T17:52:29",
            "upload_time_iso_8601": "2025-01-05T17:52:29.601674Z",
            "url": "https://files.pythonhosted.org/packages/2b/4e/6f8cbca4b1289fe90fa49bf0d10d70c7502f4372ee64a389332e20d4572f/latenpy-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-05 17:52:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "landoskape",
    "github_project": "latenpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "latenpy"
}
        
Elapsed time: 0.41872s