Metadata-Version: 2.4
Name: deco3
Version: 0.8.3
Summary: A decorator for concurrency.
Author: Alex Sherman, Adam Karpierz
Author-email: adam@karpierz.net
Maintainer: Adam Karpierz
Maintainer-email: adam@karpierz.net
License-Expression: MIT
Project-URL: Homepage, https://pypi.org/project/deco3/
Project-URL: Documentation, https://deco3.readthedocs.io/
Project-URL: Download, https://pypi.org/project/deco3/
Project-URL: Source, https://github.com/karpierz/deco3
Project-URL: Issues, https://github.com/karpierz/deco3/issues
Keywords: deco,deco3,concurrency,multiprocessing,multitasking
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: Polish
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: <4.0.0,>=3.10.0
Description-Content-Type: text/x-rst; charset=UTF-8
License-File: LICENSE
Requires-Dist: setuptools>=80.9.0
Requires-Dist: pkg-about>=1.3.6
Provides-Extra: doc
Requires-Dist: Sphinx>=8.1.3; extra == "doc"
Requires-Dist: sphinx-autodoc-typehints>=3.0.1; extra == "doc"
Requires-Dist: sphinx-toolbox>=4.0.0; extra == "doc"
Requires-Dist: sphinx-tabs>=3.4.5; extra == "doc"
Requires-Dist: sphinx-copybutton>=0.5.2; extra == "doc"
Requires-Dist: sphinxcontrib-spelling>=8.0.1; extra == "doc"
Requires-Dist: sphinx-lint>=1.0.0; extra == "doc"
Requires-Dist: restructuredtext-lint>=1.4.0; extra == "doc"
Requires-Dist: nbsphinx>=0.9.7; extra == "doc"
Provides-Extra: test
Requires-Dist: deepdiff>=8.5.0; extra == "test"
Requires-Dist: rich>=14.0.0; extra == "test"
Dynamic: license-file

deco3
=====

Decorated Concurrency.

A simplified parallel computing model for Python. DECO automatically
parallelizes Python programs, and requires minimal modifications to
existing serial programs.

Overview
========

|package_bold| is a strict fork of Alex Sherman's `deco package <deco_>`_
with a fix allowing to work with Python3 or higher and with a little code
reformatting and minor improvements.

`PyPI record`_.

`Documentation`_.

Overview below is a copy from the original `deco website <deco_>`_
(with only the necessary changes regarding |package|).

Documentation
-------------

You can reference the `Wiki on Github <deco_wiki_>`_
for slightly more in-depth documentation.

General Usage
-------------

Using DECO is as simple as finding, or creating, two functions in your
Python program. The first function is the one we want to run in
parallel, and is decorated with ``@concurrent``. The second function is
the function which calls the ``@concurrent`` function and is decorated
with ``@synchronized``. Decorating the second function is optional, but
provides some very cool benefits. Let's take a look at an example.

.. code:: python

   @concurrent  # We add this for the concurrent function
   def process_lat_lon(lat, lon, data):
     #Does some work which takes a while
     return result

   @synchronized  # And we add this for the function which calls the concurrent function
   def process_data_set(data):
     results = defaultdict(dict)
     for lat in range(...):
       for lon in range(...):
         results[lat][lon] = process_lat_lon(lat, lon, data)
     return results

That's it, two lines of changes is all we need in order to parallelize
this program. Now this program will make use of all the cores on the
machine it's running on, allowing it to run significantly faster.

What it does
------------

- The ``@concurrent`` decorator uses multiprocessing.pool to parallelize
  calls to the target function
- Indexed based mutation of function arguments is handled automatically,
  which pool cannot do
- The ``@synchronized`` decorator automatically inserts synchronization
  events
- It also automatically refactors assignments of the results of
  ``@concurrent`` function calls to happen during synchronization events

Limitations
-----------

- The ``@concurrent`` decorator will only speed up functions that take
  longer than ~1ms

  - If they take less time your code will run slower!

- By default, ``@concurrent`` function arguments/return values must be
  pickleable for use with ``multiprocessing``
- The ``@synchronized`` decorator only works on 'simple' functions, make
  sure the function meets the following criteria

  - Only calls, or assigns the result of ``@concurrent`` functions to
    indexable objects such as:

    - concurrent(...)
    - result[key] = concurrent(...)

  - Never indirectly reads objects that get assigned to by calls of the
    ``@concurrent`` function

How it works
------------

For an in depth discussion of the mechanisms at work, we wrote a paper
for a class which `can be found here <decorated_concurrency_>`_
(or original `can be found here <decorated_concurrency_org_>`_).

As an overview, DECO is mainly just a smart wrapper for Python's
multiprocessing.pool. When ``@concurrent`` is applied to a function it
replaces it with calls to pool.apply_async. Additionally when arguments
are passed to pool.apply_async, DECO replaces any index mutable objects
with proxies, allowing it to detect and synchronize mutations of these
objects. The results of these calls can then be obtained by calling
wait() on the concurrent function, invoking a synchronization event.
These events can be placed automatically in your code by using the
``@synchronized`` decorator on functions that call ``@concurrent``
functions. Additionally while using ``@synchronized``, you can directly
assign the result of concurrent function calls to index mutable objects.
These assignments get refactored by DECO to automatically occur during
the next synchronization event. All of this means that in many cases,
parallel programming using DECO appears exactly the same as simpler
serial programming.

Installation
============

Prerequisites:

+ Python 3.10 or higher

  * https://www.python.org/

+ pip and setuptools

  * https://pypi.org/project/pip/
  * https://pypi.org/project/setuptools/

To install run:

  .. parsed-literal::

    python -m pip install --upgrade |package|

Development
===========

Prerequisites:

+ Development is strictly based on *tox*. To install it run::

    python -m pip install --upgrade tox

Visit `Development page`_.

Installation from sources:

clone the sources:

  .. parsed-literal::

    git clone |respository| |package|

and run:

  .. parsed-literal::

    python -m pip install ./|package|

or on development mode:

  .. parsed-literal::

    python -m pip install --editable ./|package|

License
=======

  | |copyright|
  | Copyright (c) 2016 Alex Sherman
  | Licensed under the MIT License
  | https://opensource.org/license/mit
  | Please refer to the accompanying LICENSE file.

Authors
=======

* Alex Sherman <asherman1024@gmail.com>
* Adam Karpierz <adam@karpierz.net>

.. |package| replace:: deco3
.. |package_bold| replace:: **deco3**
.. |copyright| replace:: Copyright (c) 2025-2025 Adam Karpierz
.. |respository| replace:: https://github.com/karpierz/deco3.git
.. _Development page: https://github.com/karpierz/deco3
.. _PyPI record: https://pypi.org/project/deco3/
.. _Documentation: https://deco3.readthedocs.io/
.. _deco: https://pypi.org/project/deco/
.. _deco_wiki: https://github.com/alex-sherman/deco/wiki
.. _decorated_concurrency: _static/Decorated_Concurrency.pdf
.. _decorated_concurrency_org: https://drive.google.com/file/d/0B_olmC0u8E3gWTBmN3pydGxHdEE/view?usp=sharing&resourcekey=0-9aUctXy9Hn5g9SIul4kbVw

Changelog
=========

0.8.3 (2025-06-11)
------------------
- Setup (dependencies) update.

0.8.2 (2025-05-15)
------------------
- The distribution is now created using 'build' instead of 'setuptools'.
- Setup (dependencies) update (due to regressions in tox and setuptools).

0.8.1 (2025-05-04)
------------------
- Setup (dependencies) update.

0.8.0 (2025-04-28)
------------------
- Add support for Python 3.14
- Drop support for Python 3.9 (due to compatibility issues).
- Update readthedocs's python to version 3.13
- Update tox's base_python to version 3.13
- Setup (dependencies) update.

0.7.0 (2025-04-27)
------------------
- 100% code linting.
- Add support for PyPy 3.10 and 3.11
- Add/improve support for Python >= 3.9, <= 3.13
- Drop support for Python <= 3.8
- Drop support for Python 2.
- Copyright year update.
- | Tox configuration is now in native (toml) format (as part of
  | pyproject.toml) and now based on tox >= 4.0.
- Setup update. Currently based on pyproject.toml.
- Source distribution (\*.tar.gz now) is compliant with PEP-0625.
- Creating a fork of Alex Sherman's *deco* package with a fix allowing
  to work with Python3 or higher and newest versions of pip/setuptools.
- Minor improvements and cleanup..

Above are changes of the original (v.0.6.3) *deco*:

0.6.3 (2025-04-24)
------------------
- Initial commit.
