{"id":23116066,"url":"https://github.com/jimy-byerley/arrex","last_synced_at":"2025-08-16T21:32:19.625Z","repository":{"id":57411597,"uuid":"348046450","full_name":"jimy-byerley/arrex","owner":"jimy-byerley","description":"python module allowing to create efficient dynamic arrays of user-defined types","archived":false,"fork":false,"pushed_at":"2025-07-19T20:18:42.000Z","size":2140,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-19T21:22:38.963Z","etag":null,"topics":["array","buffer","c","cython","list","numpy","python"],"latest_commit_sha":null,"homepage":"","language":"Cython","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimy-byerley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-03-15T16:35:24.000Z","updated_at":"2025-07-19T20:18:45.000Z","dependencies_parsed_at":"2023-10-19T06:00:45.688Z","dependency_job_id":null,"html_url":"https://github.com/jimy-byerley/arrex","commit_stats":{"total_commits":102,"total_committers":1,"mean_commits":102.0,"dds":0.0,"last_synced_commit":"e76a2b83b62d78d1f6f6d9e83beb49f8ea0f6601"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/jimy-byerley/arrex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimy-byerley%2Farrex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimy-byerley%2Farrex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimy-byerley%2Farrex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimy-byerley%2Farrex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimy-byerley","download_url":"https://codeload.github.com/jimy-byerley/arrex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimy-byerley%2Farrex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270775799,"owners_count":24642961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["array","buffer","c","cython","list","numpy","python"],"created_at":"2024-12-17T04:10:50.525Z","updated_at":"2025-08-16T21:32:19.077Z","avatar_url":"https://github.com/jimy-byerley.png","language":"Cython","funding_links":[],"categories":[],"sub_categories":[],"readme":"Arrex\n-----\n\n- [documentation](https://arrex.readthedocs.io/)\n- [repository](https://github.com/jimy-byerley/pymadcad)\n\n[![support-version](https://img.shields.io/pypi/pyversions/arrex.svg)](https://img.shields.io/pypi/pyversions/arrex)\n[![PyPI version shields.io](https://img.shields.io/pypi/v/arrex.svg)](https://pypi.org/project/arrex/)\n[![Documentation Status](https://readthedocs.org/projects/arrex/badge/?version=latest)](https://arrex.readthedocs.io/en/latest/?badge=latest)\n\nArrex is a module that allows to create typed arrays much like `numpy.ndarray` and `array.array`, but resizeable and using any kind of element, not only numbers. Its dtype system is extremely flexible and makes it ideal to work and share structured data with compiled code.\n\nThe elements can be many different things, there is just 2 requirements:\n\n- they must be of a fixed binary size\n- they must be byte copiable, therefore without any reference or pointer to something else\n\n### interests\n\n- much smaller memory footprint (an arrex array is at most 30x smaller than pure python data storage)\n- content can be directly shared with compiled code which improves computation performances\n- slice \u0026 view without a copy\n- compatible with standard python libraries\n\n### basic usage:\n\n```python\n\u003e\u003e\u003e from arrex import *\n\u003e\u003e\u003e a = typedlist([\n\t\t\tmyclass(...), \n\t\t\tmyclass(...),\n\t\t\t], dtype=myclass)\n\u003e\u003e\u003e a[0]\nmyclass(...)\n```\n\nin that example, `myclass` can be a primitive numpy type, like `np.float64`\n\n```python\n\u003e\u003e\u003e import arrex.numpy\t\t# this is enabling numpy dtypes for arrex\n\u003e\u003e\u003e typedlist(dtype=np.float64)\n```\n\nit can be a more complex type, from module `pyglm` for instance\n\n```python\n\u003e\u003e\u003e import arrex.glm\t\t# this is enabling glm dtypes for arrex\n\u003e\u003e\u003e typedlist(dtype=glm.vec4)\n```\n\n`typedlist` is a dynamically sized, borrowing array, which mean the internal buffer of data is reallocated on append, but can be used to view and extract from any buffer without a copy.\n\n### Use it as a list:\n\n```python\n\u003e\u003e\u003e a = typedlist(dtype=vec3)\n\n# build from an iterable\n\u003e\u003e\u003e a = typedlist([], dtype=vec3)\n\n# append some data\n\u003e\u003e\u003e a.append(vec3(1,2,3))\n\n# extend with an iterable\n\u003e\u003e\u003e a.extend(vec3(i)  for i in range(5))\n\n\u003e\u003e\u003e len(a)\t# the current number of elements\n6\n\n\u003e\u003e\u003e a.owner\t# the current data buffer\nb'.........'\n\n\u003e\u003e\u003e a[0]\nvec3(1,2,3)\n```\n\n### Use it as a slice:\n\n```python\n\u003e\u003e\u003e myslice = a[:5]\t\t# no data is copied\ntypedlist(....)\n```\n\n### Use it as a view on top of a random buffer\n\n```python\n\u003e\u003e\u003e a = np.ones((6,3), dtype='f4')\n\u003e\u003e\u003e myslice = typedlist(a, dtype=vec3)\n```\n\n### buffer protocol\n\nIt does support the buffer protocol, so it can be converted into a great variety of well known arrays, even without any copy\n\n```python\n\u003e\u003e\u003e np.array(typedlist([....]))\n```\n\n### Which dtype is allowed\n\nanswer is: *whatever you want*, but here is some examples:\n\n```python\n# an extension type, previously declared\ntypedlist(dtype=glm.vec3)\n\n# a Struct\ntypedlist(dtype='ffxI')\n\n# a ctype\ntypedlist(dtype=ctypes.c_int*5)\n\n# a pure python class\nclass test_class:\n    __packlayout__ = 'ff'\n    _struct = struct.Struct(__packlayout__)\n\n    def __init__(self, x, y):\n        self.x = x\n        self.y = y\n\n    def __bytes__(self):\n        return self._struct.pack(self.x, self.y)\n    @classmethod\n    def frombytes(cls, b):\n        return cls(*cls._struct.unpack(b))\n\ntypedlist(dtype=test_class)\n\n# and so much more !\n```\n\n\n\n## performances\n\nTime performances comparison between `list`,  `numpy.ndarray`,  and `arrex.typedlist`  (see [benchmark](benchmark_typedlist.py) )\n\nexecution time (s) for 10k elements (dvec3)\n\n\tset item\n\t  list:         7.9847e-04 s\n\t  numpy:        1.2727e-02 s\n\t  arrex:        1.0481e-03 s  (10x faster than numpy)\n\t\n\tget item\n\t  creation:     1.0655e-03 s\n\t  list:         5.1503e-04 s\n\t  numpy:        1.8619e-03 s\n\t  arrex:        8.0111e-04 s   (2x faster than numpy)\n\n\n## Roadmap\n\nThere is additionnal features planned, but no precise schedul yet:\n\n- typedarray\n\n\ta n-dim array view much like numpy arrays but using dtypes as in `typedlist`.\n\tIts purpose is mostly to access its items with n-dim indices and slices.\n\t\n- a ufunc system\n\t\n\tto collect and put defaults to any kind of array scale operations, like `__add__`, `__mul__`, `__matmul__`, ... The goal would be to have a standard way to apply any function to every element of one or more array, that defaults to the python implementation, but can be overloaded with a compiled implementation\n\t\n- maybe \n\n\teven extend to the complete API of [numcy](https://github.com/jimy-byerley/numcy/blob/master/proposal.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimy-byerley%2Farrex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimy-byerley%2Farrex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimy-byerley%2Farrex/lists"}