Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6778621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:17:14+00:00 2026-05-26T16:17:14+00:00

In CPython, the builtin-function id(x) returns the memory address of x . Is it

  • 0

In CPython, the builtin-function id(x) returns the memory address of x.
Is it possible to reverse this ?

Something like object_by_memoryadress(id(x)) == x.

Update: The reason I need this is, because I’m using a program with embedded Python. And in this program I can create so called “Nodes” that can communicate with each other, but only with integers, strings, and stuff, but I’d need to “transfer” a list between them (which is not possible the usual way).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:17:15+00:00Added an answer on May 26, 2026 at 4:17 pm

    I have created a shared library that contains the following code:

    #include "Python.h"
    extern "C" __declspec(dllexport) PyObject* PyObjectFromAdress(long addr) {
        return (PyObject*) addr;
    }
    

    compiled it and wrapped it using ctypes:

    import ctypes
    dll = ctyes.cdll.thedll
    object_from_id = dll.PyObjectFromAdress
    object_from_id.restype = ctypes.py_object()
    

    Now you can exchange python objects through their memory adress within one python process.

    l1 = []
    l2 = object_from_id( id(l1) )
    print l1 == l2
    l1.append(9)
    print l2
    

    But be aware of already garbage collected objects ! The following code will crash the Python interpreter.

    l2 = object_from_id( id([]) )
    l2.append(8)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is basically a question about the lifetime of temporaries. If a function returns
Is this possible? Is there any thinkable way to have interop between a CPython
Is it possible to use CPython to develop Adobe Flash based applications?
I need to write a module which will be used from both CPython and
Is it possible to set a timeout on a getaddrinfo() call in CPython 2.7?
So AFAIK in CPython, function definitions are compiled into function objects when executed at
I noticed something about CPython's object deallocation which piqued my curiosity. Let's say I
I need to call CPython code from Java. What tools/APIs/libraries exist out there to
I know it is possible to use Powershell from within IronPython, but is this
Do CPython has something similar to .net c# PInvoke? For example I have some.dll

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.