| Name | pyptrs JSON |
| Version |
1.0.1
JSON |
| download |
| home_page | None |
| Summary | Real pointers and some memory utilities for python |
| upload_time | 2025-10-11 13:31:47 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | None |
| license | None |
| keywords |
memory
pointers
ptrs
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# pyptrs
This library provides real pointers (as in languages like C) and some memory access utilites.
# Installation
```pip install pyptrs```
# Creating A Pointer
You should never create pointers directly. Instead, use the functions below:
pyptrs.**pointer_to_object**(obj, c_object = False)
Return a pointer to _obj_. _c_object_ specifies whether to treat the obj as a python object or a C object.
If _c_object_ is True, obj must be an instance of a ctypes C data type.
You can learn more information about these data types from [here](https://docs.python.org/3/library/ctypes.html#fundamental-data-types), [here](https://docs.python.org/3/library/ctypes.html#arrays) and [here](https://docs.python.org/3/library/ctypes.html#structures-and-unions)
pyptrs.**pointer_to_address**(address, ctype = None)
Return a pointer that points to the given _address_. If _ctype_ is None, a python object is assumed to be living in that address.
Otherwise, _ctype_ must be the ctypes C data type corresponding to the type of the object living in _address_.
You can learn more information about these data types from [here](https://docs.python.org/3/library/ctypes.html#fundamental-data-types), [here](https://docs.python.org/3/library/ctypes.html#arrays) and [here](https://docs.python.org/3/library/ctypes.html#structures-and-unions)
# Pointer Objects
Pointer.**get_size**()
Return the number of bytes occupied by the pointed object in memory.
Pointer.**get_mem**()
Return a bytes object representing the pointed object.
Pointer.**temp_value**(value, force_write = False)
Return a context manager that dereferences and assigns _value_ to the pointed object at \_\_enter__ and reverts this assignment at \_\_exit__.
If size of _value_ is bigger than the pointed object, a MemoryError will be raised. In order to prevent this, pass True to _force_write_.
# Simulated Operators
pyptrs.**dereference**(pointer, *value, force_write = False)
If _value_ is not given, it just dereferences the _pointer_.
If _value_ is given, it must be a single argument and it dereferences the pointed object and assigns _value_ to it then returns a _backup_id_ that can be passed to pyptrs.mem_restore().
If size of _value_ is bigger than the pointed object, a MemoryError will be raised. In order to prevent this, pass True to _force_write_.
Type of _value_ can be anything if the pointed object is a python object.
If the type of the pointed object is a C type, type of _value_ must be the corresponding ctypes C data type.
pyptrs.**address_of**(obj, c_object = False)
Return address of the _obj_. If _c_object_ is True type of _obj_ must be a ctypes C data type.
You can learn more information about these data types from [here](https://docs.python.org/3/library/ctypes.html#fundamental-data-types), [here](https://docs.python.org/3/library/ctypes.html#arrays) and [here](https://docs.python.org/3/library/ctypes.html#structures-and-unions).
If _c_object_ is True, address of the actual C object is returned, not the address of its ctypes wrapper.
# Utils
pyptrs.**mem_read**(address, amount = 1)
Read _amount_ bytes starting from _address_ and return them as a bytes object.
pyptrs.**mem_write**(address, data = b"")
Write the bytes represented by _data_ to _address_ and return a _backup_id_ that can be passed to pyptrs.mem_restore().
pyptrs.**mem_restore**(backup_id)
Revert the changes done to memory by the function that returned _backup_id_.
pyptrs.**mem_restore_last**()
Revert the last change done to memory either by pyptrs.dereference() or pyptrs.mem_write().
Raw data
{
"_id": null,
"home_page": null,
"name": "pyptrs",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "memory, pointers, ptrs",
"author": null,
"author_email": "pyhacks <enginyildirim111@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ad/e6/5868fc3dc63b91484f2481712847bfe51861d1638c758dd8096537cdc08b/pyptrs-1.0.1.tar.gz",
"platform": null,
"description": "# pyptrs\nThis library provides real pointers (as in languages like C) and some memory access utilites.\n\n# Installation\n```pip install pyptrs```\n\n# Creating A Pointer\nYou should never create pointers directly. Instead, use the functions below:\n\npyptrs.**pointer_to_object**(obj, c_object = False)\n\nReturn a pointer to _obj_. _c_object_ specifies whether to treat the obj as a python object or a C object.\nIf _c_object_ is True, obj must be an instance of a ctypes C data type. \nYou can learn more information about these data types from [here](https://docs.python.org/3/library/ctypes.html#fundamental-data-types), [here](https://docs.python.org/3/library/ctypes.html#arrays) and [here](https://docs.python.org/3/library/ctypes.html#structures-and-unions)\n\npyptrs.**pointer_to_address**(address, ctype = None)\n\nReturn a pointer that points to the given _address_. If _ctype_ is None, a python object is assumed to be living in that address. \nOtherwise, _ctype_ must be the ctypes C data type corresponding to the type of the object living in _address_.\nYou can learn more information about these data types from [here](https://docs.python.org/3/library/ctypes.html#fundamental-data-types), [here](https://docs.python.org/3/library/ctypes.html#arrays) and [here](https://docs.python.org/3/library/ctypes.html#structures-and-unions)\n\n# Pointer Objects\nPointer.**get_size**()\n\nReturn the number of bytes occupied by the pointed object in memory.\n\nPointer.**get_mem**()\n\nReturn a bytes object representing the pointed object.\n\nPointer.**temp_value**(value, force_write = False)\n\nReturn a context manager that dereferences and assigns _value_ to the pointed object at \\_\\_enter__ and reverts this assignment at \\_\\_exit__.\nIf size of _value_ is bigger than the pointed object, a MemoryError will be raised. In order to prevent this, pass True to _force_write_.\n\n# Simulated Operators\n\npyptrs.**dereference**(pointer, *value, force_write = False)\n\nIf _value_ is not given, it just dereferences the _pointer_. \nIf _value_ is given, it must be a single argument and it dereferences the pointed object and assigns _value_ to it then returns a _backup_id_ that can be passed to pyptrs.mem_restore(). \nIf size of _value_ is bigger than the pointed object, a MemoryError will be raised. In order to prevent this, pass True to _force_write_.\nType of _value_ can be anything if the pointed object is a python object.\nIf the type of the pointed object is a C type, type of _value_ must be the corresponding ctypes C data type.\n\npyptrs.**address_of**(obj, c_object = False)\n\nReturn address of the _obj_. If _c_object_ is True type of _obj_ must be a ctypes C data type. \nYou can learn more information about these data types from [here](https://docs.python.org/3/library/ctypes.html#fundamental-data-types), [here](https://docs.python.org/3/library/ctypes.html#arrays) and [here](https://docs.python.org/3/library/ctypes.html#structures-and-unions).\nIf _c_object_ is True, address of the actual C object is returned, not the address of its ctypes wrapper.\n\n# Utils\npyptrs.**mem_read**(address, amount = 1)\n\nRead _amount_ bytes starting from _address_ and return them as a bytes object.\n\npyptrs.**mem_write**(address, data = b\"\")\n\nWrite the bytes represented by _data_ to _address_ and return a _backup_id_ that can be passed to pyptrs.mem_restore().\n\npyptrs.**mem_restore**(backup_id)\n\nRevert the changes done to memory by the function that returned _backup_id_.\n\npyptrs.**mem_restore_last**()\n\nRevert the last change done to memory either by pyptrs.dereference() or pyptrs.mem_write().\n",
"bugtrack_url": null,
"license": null,
"summary": "Real pointers and some memory utilities for python",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/pyhacks/pyptrs"
},
"split_keywords": [
"memory",
" pointers",
" ptrs"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4c1d2dfe76a7811527e40b9911b5b4d399ed5a08d12a4fea55e253f070c9b9eb",
"md5": "f0d391980addb5fcd3e4cd19bb550dc1",
"sha256": "32968d7520b6bc32001319e0665cc3affc53413ebe546ce114a14c2d89fa38be"
},
"downloads": -1,
"filename": "pyptrs-1.0.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "f0d391980addb5fcd3e4cd19bb550dc1",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 4581,
"upload_time": "2025-10-11T13:31:46",
"upload_time_iso_8601": "2025-10-11T13:31:46.790760Z",
"url": "https://files.pythonhosted.org/packages/4c/1d/2dfe76a7811527e40b9911b5b4d399ed5a08d12a4fea55e253f070c9b9eb/pyptrs-1.0.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ade65868fc3dc63b91484f2481712847bfe51861d1638c758dd8096537cdc08b",
"md5": "c49893e2824f698e3d184721588b3694",
"sha256": "f7c010fe4914e07390b7ffe6e11843d94c0648551e81c6d50260a9e85992050d"
},
"downloads": -1,
"filename": "pyptrs-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "c49893e2824f698e3d184721588b3694",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4976,
"upload_time": "2025-10-11T13:31:47",
"upload_time_iso_8601": "2025-10-11T13:31:47.934044Z",
"url": "https://files.pythonhosted.org/packages/ad/e6/5868fc3dc63b91484f2481712847bfe51861d1638c758dd8096537cdc08b/pyptrs-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-11 13:31:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pyhacks",
"github_project": "pyptrs",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyptrs"
}