{"id":40671529,"url":"https://github.com/sekgobela-kevin/prodius","last_synced_at":"2026-01-21T09:35:14.738Z","repository":{"id":62593086,"uuid":"546236752","full_name":"sekgobela-kevin/prodius","owner":"sekgobela-kevin","description":"Calculates cartesian product from iterables without memory error.","archived":false,"fork":false,"pushed_at":"2022-10-07T12:30:51.000Z","size":14,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-17T10:48:23.766Z","etag":null,"topics":["callables","cartesian-product","iterables","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sekgobela-kevin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-05T19:03:42.000Z","updated_at":"2023-02-10T09:58:02.000Z","dependencies_parsed_at":"2022-11-04T00:15:43.801Z","dependency_job_id":null,"html_url":"https://github.com/sekgobela-kevin/prodius","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sekgobela-kevin/prodius","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sekgobela-kevin%2Fprodius","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sekgobela-kevin%2Fprodius/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sekgobela-kevin%2Fprodius/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sekgobela-kevin%2Fprodius/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sekgobela-kevin","download_url":"https://codeload.github.com/sekgobela-kevin/prodius/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sekgobela-kevin%2Fprodius/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["callables","cartesian-product","iterables","python"],"created_at":"2026-01-21T09:35:14.132Z","updated_at":"2026-01-21T09:35:14.730Z","avatar_url":"https://github.com/sekgobela-kevin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prodius\nCalculating cartesian product is not easy if not using `itertools.product()`.\nProdius library allows to perform the same but also allowing iterables to\nbe callables that return iterable. Provided callables will be called when\niterable is needed to calculate cartesian product.\n\n`itertools.product()` ofsen raise MemoryError when one of iterables is too\nlarge. No matter matter the size of iterable, prodius will never write \nwhole iterator into memory.\n\n### Issues\n- Iterables cannot be more than 11.\n- Maybe be slower than `itertools.product()`.\n\n### Installing\nProdius can be installed with pip in your command-line.\n```bash\npip install prodius\n```\n\n### Usage\nProdius is just easy just like builtin `itertools.product()`.\n\nRealise that this wont offer any benefit as iterator are passed direcly.\n```python\nimport prodius\n\niterables = [range(10), range(10)]\nfor item in prodius.product(*iterables, repeat=2):\n    print(item)\n```\n\n\nProdius also allows iterables to contain callable that returns iterable.\n\nThe difference is that functions were used as iterables which provide\niterables on demand.\n```python\nimport prodius\n\niterables = [lambda: range(10), lambda: range(10)]\nfor item in prodius.product(*iterables, repeat=2):\n    print(item)\n```\n\nThis compares `itertools.product()` with `prodius.product()`.\n```python\nimport prodius\n\n# prodius.product() is used to calculate cartesian product.\n# No exception or MemoryError expected even if iterables are large.\niterables = [lambda: range(10**15), lambda: range(10**15)]\nproduct = prodius.product(*iterables) # works as espected\n```\n```python\nimport itertools\n\n# itertools.product() is used to calculate cartesian product.\n# MemoryError expected as iterables are too large.\niterables = [range(10**15), range(10**15)]\nproduct = itertools.product(*iterables) # MemoryError\n```\n\nProdius also gives control of over items of iterable to be used in cartesian\nproduct. That could be accomplised using `itertools.cycle()` by returning\ndifferent iterable each time function is called.\n```python\nimport prodius\nimport itertools\n\nfoods_numbers_list = [[1,2], [\"apple\", \"orange\"]]\nfoods_numbers_cycle = itertools.cycle(foods_numbers_list)\n\ndef numbers_foods():\n    return next(foods_numbers_cycle)\n\nfor item in prodius.product([100, 200], numbers_foods):\n    print(item)\n# (100, 1)\n# (100, 2)\n# (200, 'apple')\n# (200, 'orange')\n```\nNotice that `100` was matched with numbers `(1, 2)` while `200` matched with\n`('apple', 'orange')`. \n\nThats a fantastic trick with prodius even if it does not have realworld \napplication but who knows.\n\n### License\n[MIT license](https://github.com/sekgobela-kevin/prodius/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsekgobela-kevin%2Fprodius","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsekgobela-kevin%2Fprodius","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsekgobela-kevin%2Fprodius/lists"}