miniloop


Nameminiloop JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/Sekiraw/MiniLoop
SummaryMiniLoop is a lightweight Python game loop library designed to provide a simple and efficient way to manage update and render cycles in real-time applications.
upload_time2025-02-22 19:56:09
maintainerNone
docs_urlNone
authorQiyaya
requires_pythonNone
licenseApache-2.0
keywords game loop pygame render cycle
VCS
bugtrack_url
requirements setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MiniLoop

MiniLoop is a lightweight Python game loop library designed to provide a simple and efficient way to manage update and render cycles in real-time applications.

---

## Why MiniLoop? 🚀
When developing real-time applications like games and simulations, having an efficient and stable game loop is crucial. MiniLoop is designed to provide a precise, high-performance loop with built-in timing management, making it a superior alternative to a basic while loop.

- ✅ <strong>More Accurate Frame Timing</strong>
    - MiniLoop ensures consistent frame pacing by using a high-resolution timer. Unlike a simple while loop that can suffer from frame drift and timing inconsistencies, MiniLoop dynamically adjusts to keep the frame rate steady.

- ✅ <strong>Improved CPU Efficiency</strong>
    - A basic while loop can waste CPU cycles when waiting for the next frame, leading to higher power consumption and unnecessary CPU usage. MiniLoop intelligently sleeps between frames, reducing resource usage while maintaining target FPS.

- ✅ <strong>Higher FPS Stability</strong>
From our benchmarks:

MiniLoop achieved <u>60.69 FPS</u> 🔥
While loop only reached <u>58.89 FPS</u> 
This means <strong>MiniLoop maintains a smoother experience</strong>, preventing stuttering and inconsistencies.
- ✅ <strong>Optimized Python Function Calls</strong>
    - MiniLoop caches function pointers before the loop starts, minimizing overhead when calling update() and render().
A plain while loop calls Python functions inefficiently, slowing down performance.
- ✅ <strong>Cross-Platform & Easy to Use</strong>
    - Works on Windows, Linux, and macOS with precise timing control.
Simple API: just set your update() and render() functions, and MiniLoop takes care of the rest.
- ✅ <strong>Built-In Stop Handling</strong>
    - MiniLoop includes a clean stop mechanism that allows safe termination from Python, unlike a while loop that may require manual handling with try/except.

💡 TL;DR
- ✅ More stable FPS
- ✅ Lower CPU usage
- ✅ Better timing accuracy
- ✅ Easier to use

If you're working on a game, simulation, or any real-time application, MiniLoop is the better choice. Try it out and experience a smoother, more efficient loop! 🚀🔥

## Features

- High-performance game loop with adjustable FPS
- Support for user-defined update and render callbacks
- Cross-platform high-resolution timer
- Simple start/stop functionality

---

## Requirements

- Python 3.x (recommended: 3.7 or higher)

---

## Installation

Install the package using pip:

```bash
pip install miniloop
```

## Usage
Here is an example of how to use MiniLoop:

```python
import miniloop

def update(delta_time):
    print(f"Update: {delta_time:.5f} sec")

def render():
    print("Rendering frame")

miniloop.set_update(update)
miniloop.set_render(render)
miniloop.set_fps(60)  # Target 60 FPS

miniloop.start()
```
## Output Example
```plaintext
Update: 0.01667 sec
Rendering frame
Update: 0.01665 sec
Rendering frame
...
```

## How It Works
MiniLoop miniloop runs a continuous loop, calling the user-defined update and render functions at a target frame rate. The update function receives delta_time, which represents the time elapsed since the last frame, allowing smooth time-based updates.

## Limitations
- Currently limited to single-threaded execution.
- No built-in event handling; input handling must be managed externally.

## Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.

## Local Development
To set up a local development environment, follow these steps:

1. Create and activate a virtual environment:
    ```bash
    source venv/bin/activate  # macOS/Linux
    venv\Scripts\activate     # Windows
    venv/Scripts/activate
    ```
2. Build & install the project
    ```bash
    python setup.py build
    python setup.py install
    ```
The module is now installed in the virtual environment. You can test it by running the example script:

```bash
python examples/example.py
```


## License
This project is licensed under the Apache-2.0 License. See the LICENSE file for details.

## Author
Developed by Sekiraw

## Acknowledgements
Thanks to the Python development community for providing tools and resources to make this project possible.

```vbnet
This styling ensures clarity, proper sectioning, and good readability. Let me know if you`d like any further adjustments!
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Sekiraw/MiniLoop",
    "name": "miniloop",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "GAME, LOOP, PYGAME, RENDER, CYCLE",
    "author": "Qiyaya",
    "author_email": "v2020.bohus.peter@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8b/ab/186ca6847d53a37a1013524247d8fbcd3c6afcd53923a0ff8b7fa0aa3933/miniloop-1.0.0.tar.gz",
    "platform": null,
    "description": "# MiniLoop\r\n\r\nMiniLoop is a lightweight Python game loop library designed to provide a simple and efficient way to manage update and render cycles in real-time applications.\r\n\r\n---\r\n\r\n## Why MiniLoop? \u00f0\u0178\u0161\u20ac\r\nWhen developing real-time applications like games and simulations, having an efficient and stable game loop is crucial. MiniLoop is designed to provide a precise, high-performance loop with built-in timing management, making it a superior alternative to a basic while loop.\r\n\r\n- \u00e2\u0153\u2026 <strong>More Accurate Frame Timing</strong>\r\n    - MiniLoop ensures consistent frame pacing by using a high-resolution timer. Unlike a simple while loop that can suffer from frame drift and timing inconsistencies, MiniLoop dynamically adjusts to keep the frame rate steady.\r\n\r\n- \u00e2\u0153\u2026 <strong>Improved CPU Efficiency</strong>\r\n    - A basic while loop can waste CPU cycles when waiting for the next frame, leading to higher power consumption and unnecessary CPU usage. MiniLoop intelligently sleeps between frames, reducing resource usage while maintaining target FPS.\r\n\r\n- \u00e2\u0153\u2026 <strong>Higher FPS Stability</strong>\r\nFrom our benchmarks:\r\n\r\nMiniLoop achieved <u>60.69 FPS</u> \u00f0\u0178\u201d\u00a5\r\nWhile loop only reached <u>58.89 FPS</u> \r\nThis means <strong>MiniLoop maintains a smoother experience</strong>, preventing stuttering and inconsistencies.\r\n- \u00e2\u0153\u2026 <strong>Optimized Python Function Calls</strong>\r\n    - MiniLoop caches function pointers before the loop starts, minimizing overhead when calling update() and render().\r\nA plain while loop calls Python functions inefficiently, slowing down performance.\r\n- \u00e2\u0153\u2026 <strong>Cross-Platform & Easy to Use</strong>\r\n    - Works on Windows, Linux, and macOS with precise timing control.\r\nSimple API: just set your update() and render() functions, and MiniLoop takes care of the rest.\r\n- \u00e2\u0153\u2026 <strong>Built-In Stop Handling</strong>\r\n    - MiniLoop includes a clean stop mechanism that allows safe termination from Python, unlike a while loop that may require manual handling with try/except.\r\n\r\n\u00f0\u0178\u2019\u00a1 TL;DR\r\n- \u00e2\u0153\u2026 More stable FPS\r\n- \u00e2\u0153\u2026 Lower CPU usage\r\n- \u00e2\u0153\u2026 Better timing accuracy\r\n- \u00e2\u0153\u2026 Easier to use\r\n\r\nIf you're working on a game, simulation, or any real-time application, MiniLoop is the better choice. Try it out and experience a smoother, more efficient loop! \u00f0\u0178\u0161\u20ac\u00f0\u0178\u201d\u00a5\r\n\r\n## Features\r\n\r\n- High-performance game loop with adjustable FPS\r\n- Support for user-defined update and render callbacks\r\n- Cross-platform high-resolution timer\r\n- Simple start/stop functionality\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- Python 3.x (recommended: 3.7 or higher)\r\n\r\n---\r\n\r\n## Installation\r\n\r\nInstall the package using pip:\r\n\r\n```bash\r\npip install miniloop\r\n```\r\n\r\n## Usage\r\nHere is an example of how to use MiniLoop:\r\n\r\n```python\r\nimport miniloop\r\n\r\ndef update(delta_time):\r\n    print(f\"Update: {delta_time:.5f} sec\")\r\n\r\ndef render():\r\n    print(\"Rendering frame\")\r\n\r\nminiloop.set_update(update)\r\nminiloop.set_render(render)\r\nminiloop.set_fps(60)  # Target 60 FPS\r\n\r\nminiloop.start()\r\n```\r\n## Output Example\r\n```plaintext\r\nUpdate: 0.01667 sec\r\nRendering frame\r\nUpdate: 0.01665 sec\r\nRendering frame\r\n...\r\n```\r\n\r\n## How It Works\r\nMiniLoop miniloop runs a continuous loop, calling the user-defined update and render functions at a target frame rate. The update function receives delta_time, which represents the time elapsed since the last frame, allowing smooth time-based updates.\r\n\r\n## Limitations\r\n- Currently limited to single-threaded execution.\r\n- No built-in event handling; input handling must be managed externally.\r\n\r\n## Contributing\r\nContributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.\r\n\r\n## Local Development\r\nTo set up a local development environment, follow these steps:\r\n\r\n1. Create and activate a virtual environment:\r\n    ```bash\r\n    source venv/bin/activate  # macOS/Linux\r\n    venv\\Scripts\\activate     # Windows\r\n    venv/Scripts/activate\r\n    ```\r\n2. Build & install the project\r\n    ```bash\r\n    python setup.py build\r\n    python setup.py install\r\n    ```\r\nThe module is now installed in the virtual environment. You can test it by running the example script:\r\n\r\n```bash\r\npython examples/example.py\r\n```\r\n\r\n\r\n## License\r\nThis project is licensed under the Apache-2.0 License. See the LICENSE file for details.\r\n\r\n## Author\r\nDeveloped by Sekiraw\r\n\r\n## Acknowledgements\r\nThanks to the Python development community for providing tools and resources to make this project possible.\r\n\r\n```vbnet\r\nThis styling ensures clarity, proper sectioning, and good readability. Let me know if you`d like any further adjustments!\r\n```\r\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "MiniLoop is a lightweight Python game loop library designed to provide a simple and efficient way to manage update and render cycles in real-time applications.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/Sekiraw/MiniLoop"
    },
    "split_keywords": [
        "game",
        " loop",
        " pygame",
        " render",
        " cycle"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "59ecbbc99e076bc0610144da4dd7a33926ac6cd91bfd20b9b6630afb0eecd08d",
                "md5": "173eac964c3a3a4c85190e55115a4aa0",
                "sha256": "99df314cecfa6241d4ecf498e7f678526c605ff6e0725c43a85911eeebd81d4f"
            },
            "downloads": -1,
            "filename": "miniloop-1.0.0-cp313-cp313-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "173eac964c3a3a4c85190e55115a4aa0",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": null,
            "size": 13617,
            "upload_time": "2025-02-22T19:56:07",
            "upload_time_iso_8601": "2025-02-22T19:56:07.876273Z",
            "url": "https://files.pythonhosted.org/packages/59/ec/bbc99e076bc0610144da4dd7a33926ac6cd91bfd20b9b6630afb0eecd08d/miniloop-1.0.0-cp313-cp313-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8bab186ca6847d53a37a1013524247d8fbcd3c6afcd53923a0ff8b7fa0aa3933",
                "md5": "9508e4d22c12c82b1dbe23a7f0c3958d",
                "sha256": "03037028310c1d3fc760eea31ac0d0fba99e610ed9da8d68e5659b708fa431ae"
            },
            "downloads": -1,
            "filename": "miniloop-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9508e4d22c12c82b1dbe23a7f0c3958d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8823,
            "upload_time": "2025-02-22T19:56:09",
            "upload_time_iso_8601": "2025-02-22T19:56:09.777859Z",
            "url": "https://files.pythonhosted.org/packages/8b/ab/186ca6847d53a37a1013524247d8fbcd3c6afcd53923a0ff8b7fa0aa3933/miniloop-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-22 19:56:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Sekiraw",
    "github_project": "MiniLoop",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "setuptools",
            "specs": []
        }
    ],
    "lcname": "miniloop"
}
        
Elapsed time: 1.49062s