[ctypes-users] A recursive Structure
by Lenard Lindstrom other posts by this author
Nov 16 2006 2:02PM messages near this date
Re: [ctypes-users] PYFUNCTYPE, py_object and reference counting
|
Re: [ctypes-users] A recursive Structure
The following ctypes structure example is decidedly un-C-like:
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more
information.
> >> from ctypes import Structure, c_int, sizeof, __version__
> >> __version__
'1.0.1'
> >> class S(Structure):
... pass
...
> >> S._fields_ = [('i', c_int), ('s', S)]
> >> sizeof(S)
4
> >> o=S(7)
> >> o.s.i=12
> >> o.s.s.i=20
> >> o.i
7
> >> o.s.i
12
> >> o.s.s.i
20
> >> sizeof(o)
4
This is certainly a novel way to create a singly-linked list. But I
wonder if I want to know what it is doing to memory behind the
scenes.
Lenard Lindstrom
<len-l@[...].net>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
ctypes-users mailing list
ctypes-users@[...].net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Thread:
Lenard Lindstrom
Thomas Heller
|