Recently I'm trying to transfer from python2 to python3,in my codes there is some job about read data form hardware that have a .py interface file call foreign .dll lib. The data is shared by memory between .dll and python routine,specifically speaking, ctypes.creat_string_buffer() and ctypes.addressof(), which run correctly under python2.7 env,but give unexpected result under python3.6, the reason seems to be that ctypes.addressof() give huge difference address value, I wonder what's the reason?
'''python2.7 output of addressof()
(base) C:\Users\Administrator>python
Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 18:37:09) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> s = 128
>>> p = create_string_buffer(s)
>>> print(addressof(p))
50341488
>>> hex(addressof(p))
'0x3002670L'
'''
'''python3.6 output of addressof()
(base) C:\Users\Administrator>conda activate py36
(py36) C:\Users\Administrator>python
Python 3.6.8 |Anaconda, Inc.| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> s = 128
>>> p = create_string_buffer(s)
>>> print(addressof(p))
>>> 2241150277680
>>> hex(addressof(p))
>>> '0x209cef75830'
'''
In my opinion,the output of addressof() funtion under python2 and python3 should be approximate,but in fact it's not。Some one who can help me to point what's wrong with the routine,or with me , appreciatively!