Make a quick experiment under version 3.4.4 through this simple "tool" Chris
had provided, now I know how the unicode string was stored in memory:-)
>>> s1 = '\x80abc'
>>> s1
'\x80abc'
>>> len(s1)
4
>>> sys.getsizeof(s1)
41
>>> s1ptr = ctypes.cast(id(s1), ctypes.POINTER(ctypes.c_uint8))
>>>
On Sat, May 21, 2016 at 2:47 PM, wrote:
> It's amazing the "tool" is so simple. Actually I feel a little embarrassed
> that I do know every statements in it but just no idea of combining them
> together. Thanks a lot, Chris.
>
It's a pretty complicated tool, actually -
On Sat, 21 May 2016 11:05 am, jf...@ms4.hinet.net wrote:
> Is there any tools which can do the memory dump of an object so I can view
> their content or implementation?
No standard tool. There may be third-party tools, but they would be
implementation-specific.
> For example,
>
s1 =
Sorry, forget to mention that I am working on version 3.4
Following the steps given in Chris's reply, I get the result from bytes string:
>>> b1 = b'\x80abc'
>>> ctypes.cast(id(b1), ctypes.c_voidp)
c_void_p(35495992)
>>> sys.getsizeof(b1)
21
>>> b1ptr = ctypes.cast(id(b1),
On Sat, May 21, 2016 at 11:05 AM, wrote:
> Is there any tools which can do the memory dump of an object so I can view
> their content or implementation? For example,
>
s1 = '\x80abc'
b1 = b'\x80abc'
>
> What are exactly stored in memory for each of them? Is their
On Friday, May 20, 2016 at 9:05:51 PM UTC-4, jf...@ms4.hinet.net wrote:
> Is there any tools which can do the memory dump of an object so I can view
> their content or implementation? For example,
>
> >>> s1 = '\x80abc'
> >>> b1 = b'\x80abc'
>
> What are exactly stored in memory for each of
Is there any tools which can do the memory dump of an object so I can view
their content or implementation? For example,
>>> s1 = '\x80abc'
>>> b1 = b'\x80abc'
What are exactly stored in memory for each of them? Is their content really the
same? This kind of tool should be helpful "for me" to