Skip to main content

Groupcast

Groupcast is a lightweight Python utility for broadcasting method calls and aggregating attribute access across a group of objects — as if they were a single entity.

It supports both serial and parallel execution modes, along with list-like behavior (iteration, indexing, appending, popping).


Features

  • ✅ Broadcast method calls across objects (group.method(args))
  • ✅ Access non-callable attributes as aggregated lists (group.attr)
  • ✅ Switch between serial and parallel execution modes
  • ✅ Direct control via apply() for methods and get() for attributes
  • ✅ List-like behavior: len(), [], iteration, append(), pop()

Installation

This library is instable via pip using the command pip install groupcast, if you would rather not use pip, you could also just drop this file into your project and import it that way.

Simple Usage

class Example:
    def __init__(self, x):
        self.x = x
    def double(self):
        return(self.x * 2)
inputs = [[1], [2], [3]]
group = groupcast.Group(Example, inputs=inputs) 
print(group.x)
# should result in [1, 2, 3]

print(group.double())
# should result in [2, 4, 6]

print(group[0].x)    #< to only print the value for the first object
# should result in 1

Constructor

Group(inputs=None, class_=None, objects=None, parallel=False, maxWorkers=None)

You can initialize a Group in two ways:

  1. Using class_:

    • Creates a list of objects by creating the class_ constructor.
  2. Using objects directly:

    • Pass in a list of pre-created objects.

If neither objects nor class_ is provided, a TypeError is raised.

Execution Modes

Use .changeExecutionMode(parallel=True, maxWorkers=...) to toggle between:

  • Serial mode (default): runs method calls one after another.

  • Parallel mode: runs method calls concurrently using threads.

To change modes, use the following:
group.changeExecutionMode(parallel=True) # now runs in parallel
You can also set it to false to return back to serial mode

Attribute & Method Access

  • group.attr returns a list of attribute values (e.g., group.x will return [x1,x2,x3,x4] for every object)

  • group.method(*args) broadcasts the call across all objects and will return the results

  • For explicit control:

    • group.get("attrName")

    • group.apply("methodName", *args)


Appending & Removing

To append, you can use the append and pass the same varibles as you pass to init
EX: group.append(input=4, class_=Example) will add a new Example object initialized with the value 4

You can append using either class_, or a ready object.

Example Use Cases

  • Managing multiple similar sensor or device objects.

  • Group operations on widgets, models, or entities in simulations/games.

  • Synchronous control of multiple instances for testing or broadcasting commands.

License

MIT License (see LICENSE file for more information)

Metadata

Release files for groupcast 1.1.2

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

Source distribution (sdist)

Source distribution for groupcast 1.1.2
File Size Uploaded
groupcast-1.1.2.tar.gz 4.3 kB Details

Built distribution (wheel)

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

Total release size: 8.9 kB

Release files / groupcast-1.1.2.tar.gz

Download URL groupcast-1.1.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0cbc76a79c0776da9893649004073c6cb19930a225d81282cdf03f2ee46a146a
BLAKE2b-256 checksum
How to use checksums
186679295b0fa5b0dc26851d988b8c822b35d3c629e902ba4b5eb39d33a4032d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / groupcast-1.1.2-py3-none-any.whl

Download URL groupcast-1.1.2-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b413d2acc95aa003baf8da3af14e753528fa61267f8561f74b49062375cdc46
BLAKE2b-256 checksum
How to use checksums
4afb97c4c036a668f379428f7453e7394fc4bfa1563d7927df4162ae3413b409
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

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