{"id":18552297,"url":"https://github.com/cuspaceflight/magicmemoryview","last_synced_at":"2025-06-13T04:06:07.576Z","repository":{"id":19334837,"uuid":"22573597","full_name":"cuspaceflight/magicmemoryview","owner":"cuspaceflight","description":"Magic memoryview() style casting for Cython","archived":false,"fork":false,"pushed_at":"2014-08-10T12:19:42.000Z","size":179,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-15T11:12:10.152Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuspaceflight.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-03T11:29:18.000Z","updated_at":"2022-06-19T22:23:22.000Z","dependencies_parsed_at":"2022-08-28T03:21:21.419Z","dependency_job_id":null,"html_url":"https://github.com/cuspaceflight/magicmemoryview","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cuspaceflight/magicmemoryview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuspaceflight%2Fmagicmemoryview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuspaceflight%2Fmagicmemoryview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuspaceflight%2Fmagicmemoryview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuspaceflight%2Fmagicmemoryview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuspaceflight","download_url":"https://codeload.github.com/cuspaceflight/magicmemoryview/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuspaceflight%2Fmagicmemoryview/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259578199,"owners_count":22879213,"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","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":[],"created_at":"2024-11-06T21:13:44.374Z","updated_at":"2025-06-13T04:06:07.556Z","avatar_url":"https://github.com/cuspaceflight.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"A helper / hack to allow us to cast a ``mmap.mmap`` or other buffer to\na Cython pointer of the correct type.\n\nCython is capable of casting a lot of things to a C pointer of the\ncorrect type, especially with the aid of ``memoryview``. However,\nin Python 2, ``memoryview`` lacks the ``memoryview.cast`` method\n(so Cython won't let us change the dimensions of the array). Further,\nboth Python 2 and 3 require the memory map to be writable (making\nthe pointer type ``const`` does not seem to help here either).\n\nThis class takes a (possibly read-only) memmap object, and produces a\nPython object with a ``__getbuffer__`` method that returns The Right Thing.\n*It pretends that the underlying buffer is writable* to make Cython\nhappy. If you give it a read-only buffer, and try to write to the result,\nthen you will have a bad time.\n\nWhen a Python object is cast by Cython to a pointer, it holds a\nreference to the underlying Python object in order to prevent the\nmemory to which it refers being garbage collected. The ``MagicMemoryView``\nin turn keeps a reference to the underlying data, so everything should\nbehave as expected.\n\nUsage::\n\n    from magicmemoryview import MagicMemoryView\n\n    cdef double data[:, :, :]\n\n    data = MagicMemoryView(source_buffer, (24, 12, 25), \"d\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuspaceflight%2Fmagicmemoryview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuspaceflight%2Fmagicmemoryview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuspaceflight%2Fmagicmemoryview/lists"}