1

I wore wondering if there was a of getting a pointer (python pointer and not ctype pointer) from a memory address caught by a id() function call. This is the desired use case:

target = ['list','is','used','since', 'its', 'mutable']
tID = id(target)

pointerToTarget = getPointerFromID(tID)

# this has to be executed in such a way that 
# id(pointerToTarget) == id(target) (same as pointerToTarget is target) returns true

pointerToTarget[0] = 'string'; pointerToTarget[-1] = 'Immutable'

print(target)

If the operation is successful the code above will print: ['string','is','used','since', 'its', 'Immutable']

Equilibris
  • 49
  • 1
  • 4
  • Equilibris: Note that using `PyObj_FromPtr()` only works on the cPython interpreter — you'll need to use something else for interpreters implemented in other computer languages. – martineau Oct 12 '19 at 19:09

0 Answers0