Python C Object Comparison

Discussion in 'Python' started by Anand K Rayudu, Jan 6, 2005.

  1. Dear All,

    I have some question regarding embedding and exposing of C pointers.

    We have embedded python and extended to expose our APIs and c objects to
    python.
    Every thing is working fine as far as customizing our application
    through python.

    How ever i am expecting following behavior but it failed. Can some oe
    suggest a work around!!

    Here is my python code

    import myModule

    a=myModule.myAPI1("1")
    b=myModule.myAPI2("name")

    # basically both above functions return same C pointer.
    # so i want to compare
    if(a==b): print "They are same"
    else : print "They are different"

    python always prints they are different,
    I guess this is because in python layer we create PythonCObject for
    every C pointer, and that is how it is exposed to python. Though both
    the APIs are returning the same C pointer, they are different instances
    of PythonCObject.
    So i guess that is the reason comparison is failing.
    How ever is it possible to make python to compare actual C pointer,
    rather than the PythonCObject Pointer.

    Can some one please suggest

    Regards,
    Anand
     
    Anand K Rayudu, Jan 6, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jens Thiede

    Comparison: C++, C, Python, Java

    Jens Thiede, Jun 16, 2004, in forum: C++
    Replies:
    6
    Views:
    3,695
    Pete C.
    Jun 16, 2004
  2. D. Susman
    Replies:
    19
    Views:
    652
    Jerry Coffin
    Mar 19, 2008
  3. Kay Schluehr
    Replies:
    7
    Views:
    294
    Terry Reedy
    May 17, 2008
  4. Mark
    Replies:
    26
    Views:
    674
    jacob navia
    Mar 5, 2011
  5. Deepu
    Replies:
    1
    Views:
    250
    ccc31807
    Feb 7, 2011
Loading...

Share This Page