473,729 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where are the strings in gc.get_objects?

Hello all. I'm tracking down memory leaks in my app. To do this I wrote a
script to show the numbers of each different type of object. But it doesn't
show strings! Here is the script:

import gc,types

def printDict(d):
keys = d.keys() ; keys.sort()
print '-' * 30
for key in keys:
n = d.get(key)
print '%+6d %s' % (n,key)

d = {} ; d2 = {}
for obj in gc.get_objects( ):
t = type(obj)
r = repr(t)
n = d.get(r,0)
d[r] = n + 1
if t == types.InstanceT ype:
t = obj.__class__
r = repr(t)
n = d2.get(r,0)
d2[r] = n + 1

printDict(d)
printDict(d2)

And here is example output. The first part of the listing shows the 'raw'
type of each object, the second part of the listing shows
type(obj.__clas s__) for instance types.

------------------------------
+1925 <class 'leoGlobals.Bun ch'>
+1 <class 'leoNodes.nodeI ndices'>
+47 <class 'leoNodes.posit ion'>
+2858 <class 'leoNodes.tnode '>
+2877 <class 'leoNodes.vnode '>
+1 <class 'random.Random' >
+1 <class 'site._Helper'>
+3 <class 'site._Printer' >
+1 <class 'string._Templa teMetaclass'>
+1 <class 'threading._Con dition'>
+1 <class 'threading._Mai nThread'>
+1 <class 'unittest.TestL oader'>
+536 <type 'builtin_functi on_or_method'>
+27 <type 'cell'>
+1 <type 'classmethod'>
+1 <type 'classmethod_de scriptor'>
+538 <type 'classobj'>
+11942 <type 'dict'>
+14 <type 'frame'>
+8493 <type 'function'>
+3 <type 'generator'>
+70 <type 'getset_descrip tor'>
+1997 <type 'instance'>
+3704 <type 'instancemethod '>
+4441 <type 'list'>
+72 <type 'member_descrip tor'>
+226 <type 'method_descrip tor'>
+181 <type 'module'>
+1 <type 'property'>
+29740 <type 'tuple'>
+1 <type 'tupleiterator' >
+53 <type 'type'>
+105 <type 'weakref'>
+362 <type 'wrapper_descri ptor'>
------------------------------
+1 <class Pmw.Pmw_1_2.lib .PmwLoader.PmwL oader at 0x0156D390>
+1 <class Tkinter.BitmapI mage at 0x0154E5D0>
+30 <class Tkinter.Button at 0x0154E270>
+1 <class Tkinter.CallWra pper at 0x0154E030>
+5 <class Tkinter.Canvas at 0x0154E2A0>
+9 <class Tkinter.Checkbu tton at 0x0154E2D0>
+1 <class Tkinter.Event at 0x01540EA0>
+51 <class Tkinter.Frame at 0x0154E330>
+15 <class Tkinter.IntVar at 0x01540F30>
+11 <class Tkinter.Label at 0x0154E360>
+3 <class Tkinter.Listbox at 0x0154E390>
+61 <class Tkinter.Menu at 0x0154E3C0>
+7 <class Tkinter.PhotoIm age at 0x0154E5A0>
+3 <class Tkinter.Radiobu tton at 0x0154E450>
+19 <class Tkinter.Scrollb ar at 0x0154E4B0>
+5 <class Tkinter.StringV ar at 0x01540F00>
+1 <class Tkinter.Tk at 0x0154E0C0>
+9 <class Tkinter.Topleve l at 0x0154E240>
+6 <class _Pmw.Pmw_1_2.li b.PmwBalloon.Ba lloon at 0x0186D870>
+1545 <class _Pmw.Pmw_1_2.li b.PmwBase.__Tki nterCallWrapper at 0x015A66F0>
+2 <class _Pmw.Pmw_1_2.li b.PmwNoteBook.N oteBook at 0x0162ECF0>
+1 <class _Pmw.Pmw_1_2.li b.PmwPanedWidge t.PanedWidget at 0x016FA360>
+2 <class _Pmw.Pmw_1_2.li b.PmwScrolledFr ame.ScrolledFra me at 0x016FADE0>
+3 <class __future__._Fea ture at 0x00EB6840>
+2 <class compiler.misc.S et at 0x00E899C0>
+1 <class compiler.pyasse m.StackDepthTra cker at 0x00E89B10>
+3 <class doctest.DocTest Parser at 0x00EE50C0>
+2 <class encodings.cp125 2.Codec at 0x00ADE1E0>
+2 <class encodings.cp437 .Codec at 0x00CF0AE0>
+1 <class exceptions.Memo ryError at 0x00A87120>
+1 <class leoApp.LeoApp at 0x00BAF930>
+3 <class leoAtFile.atFil e at 0x00DBF180>
+3 <class leoChapters.cha pter at 0x015D6660>
+1 <class leoChapters.cha pterController at 0x015D6630>
+1 <class leoColor.colori zer at 0x00CCA8A0>
+2 <class leoColor.nullCo lorizer at 0x00CCA8D0>
+3 <class leoCommands.Com mands at 0x00FE1900>
+3 <class leoCommands.con figSettings at 0x00FE1930>
+1 <class leoConfig.confi gClass at 0x00CF03C0>
+1 <class leoConfig.setti ngsTreeParser at 0x00CF03F0>
+1 <class leoEditCommands .AspellClass at 0x00F20E40>
+3 <class leoEditCommands .abbrevCommands Class at 0x00F15810>
+3 <class leoEditCommands .bufferCommands Class at 0x00F20B10>
+3 <class leoEditCommands .controlCommand sClass at 0x00F20B40>
+3 <class leoEditCommands .debugCommandsC lass at 0x00F20B70>
+3 <class leoEditCommands .editCommandsCl ass at 0x00F20BA0>
+3 <class leoEditCommands .editFileComman dsClass at 0x00F20BD0>
+3 <class leoEditCommands .helpCommandsCl ass at 0x00F20C00>
+3 <class leoEditCommands .keyHandlerComm andsClass at 0x00F20C30>
+3 <class leoEditCommands .killBufferComm andsClass at 0x00F20C60>
+3 <class leoEditCommands .leoCommandsCla ss at 0x00F20C90>
+3 <class leoEditCommands .macroCommandsC lass at 0x00F20CC0>
+3 <class leoEditCommands .queryReplaceCo mmandsClass at 0x00F20CF0>
+3 <class leoEditCommands .rectangleComma ndsClass at 0x00F20D20>
+3 <class leoEditCommands .registerComman dsClass at 0x00F20D50>
+3 <class leoEditCommands .searchCommands Class at 0x00F20DB0>
+3 <class leoEditCommands .spellCommandsC lass at 0x00F20DE0>
+1 <class leoEditCommands .spellTabHandle r at 0x00F20E10>
+3 <class leoFileCommands .fileCommands at 0x00F932D0>
+3 <class leoFind.leoFind at 0x00C12840>
+5 <class leoFind.searchW idget at 0x00C12810>
+2 <class leoFrame.nullBo dy at 0x00CF0210>
+2 <class leoFrame.nullFr ame at 0x00CF0240>
+2 <class leoFrame.nullIc onBarClass at 0x00CF0270>
+2 <class leoFrame.nullLo g at 0x00CF02A0>
+2 <class leoFrame.nullTr ee at 0x00CF0300>
+6 <class leoFrame.string TextWidget at 0x00CF00F0>
+2 <class leoGlobals.redi rectClass at 0x00BAF420>
+2 <class leoGui.nullGui at 0x00CF0330>
+3 <class leoImport.leoIm portCommands at 0x00F93FC0>
+3 <class leoKeys.autoCom pleterClass at 0x00E70720>
+3 <class leoKeys.classSc annerClass at 0x00E70600>
+3 <class leoKeys.forgivi ngParserClass at 0x00E705D0>
+2 <class leoKeys.keyHand lerClass at 0x00E707B0>
+2 <class leoMenu.nullMen u at 0x00CDDCC0>
+3 <class leoTangle.tangl eCommands at 0x00FE1750>
+1 <class leoTkinterFind. tkFindTab at 0x015AF630>
+1 <class leoTkinterFind. tkSpellTab at 0x015AF660>
+12 <class leoTkinterFind. underlinedTkBut ton at 0x015AF5D0>
+20 <class leoTkinterFrame .leoTkTextWidge t at 0x016006F0>
+1 <class leoTkinterFrame .leoTkinterBody at 0x016005D0>
+1 <class leoTkinterFrame .leoTkinterFram e at 0x01600660>
+1 <class leoTkinterFrame .leoTkinterLog at 0x01600690>
+1 <class leoTkinterFrame .leoTkinterTree Tab at 0x016006C0>
+1 <class leoTkinterFrame .tkIconBarClass at 0x01600630>
+1 <class leoTkinterFrame .tkStatusLineCl ass at 0x01600600>
+1 <class leoTkinterGui.l eoKeyEvent at 0x015B77B0>
+1 <class leoTkinterGui.t kinterGui at 0x01600720>
+1 <class leoTkinterKeys. tkinterKeyHandl erClass at 0x016FA990>
+1 <class leoTkinterMenu. leoTkinterMenu at 0x015DB150>
+3 <class leoTkinterTree. leoTkinterTree at 0x016004E0>
+3 <class leoUndo.undoer at 0x00CF0090>
+1 <class mod_scripting.s criptingControl ler at 0x0162E060>
+1 <class nav_buttons.ima geClass at 0x0162E990>
+1 <class nav_buttons.mar ksDialog at 0x0162E9C0>
+1 <class nav_buttons.rec entSectionsDial og at 0x0162EA20>
+1 <class os._Environ at 0x00A9BC30>
+5 <class plugins_menu.Pl ugIn at 0x01540270>
+1 <class plugins_menu._P luginDatabase at 0x01527B40>
+2 <class repr.Repr at 0x00EDB690>
+10 <class tkFont.Font at 0x015DB120>
+2 <class xml.sax.handler .ErrorHandler at 0x00F75360>

I get similar results on both Python 2.4 and Python 2.5. I'm running on XP.

Can anyone explain were the strings are? I expect at least twice the number
of strings as there are leoNodes.vnode objects.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@chart er.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
May 4 '07 #1
1 2021
The following script dumps all objects allocated since the last time it was
called. It suppresses the dump if more than 200 new objects were allocated.
g.app.idDict is a dict whose keys are id(obj) and whose values are obj.
(g.app.idDict will persist between invocations of the script). This allows
us to determine whether an object has already been allocated. It's not a
perfect test,but perfection is not required.

As expected, this stresses the gc a lot. The isLargeItem function is
important: it returns True if repr(obj) would be too big. It tries to avoid
actually generating repr(obj). Even so, sometimes the script appears to hang
while isLargeItem cranks. I thought it would be clever to call isLargeItem
for dict values, but that overflowed the stack.

Anyway, here is the script:

import gc,types

def isLargeItem (obj):

.....if (
.........type(o bj) == types.CodeType or
.........type(o bj) == types.ListType and len(obj) 500 or
.........type(o bj) == types.TupleType and len(obj) 500
.....):
.........return True

.....if type(obj) == types.DictType:
.........n = 0 ; keys = obj.keys()
.........if len(keys) 100: return True
.........for key in keys:
.............va l = obj.get(key)
.............# if isLargeItem(val ): return True
.............n += len(repr(key))
.............n += len(repr(val))
.............if n 1000: return True
.........return False
.............
.....return len(repr(obj)) 1000

try: d = g.app.idDict
except AttributeError: d = g.app.idDict = {}

new = {}
for obj in gc.get_objects( ):
.....oldObj = d.get(id(obj))
.....if oldObj is None:
.........new[id(obj)] = obj
.........
keys = new.keys()
print '----- %d new objects' % len(keys)

if len(keys) < 200:
.....keys.sort( )
.....n = 0
.....for key in keys:
.........n += 1
.........obj = new.get(key)
.........print '%3d' % (n),key,type(ob j),
.........if isLargeItem(obj ):
.............pr int '***** large item'
.........else:
.............pr int repr(obj)
.....print '====='

for key in keys:
.....d[key] = new.get(key)

And here is some example output:

----- 70129 new objects [first run of script: nothing printed]
----- 118 new objects [second run of script]
1 13723776 <type 'frame'<frame object at 0x00D16880>
2 17053392 <type 'frame'<frame object at 0x010436D0>
3 20219840 <type 'frame'<frame object at 0x013487C0>
4 21927208 <type 'frame'<frame object at 0x014E9528>
5 23088536 <type 'tuple'('5780', '??', '??', '??', '66', '4', '4522765',
'??', '115', '174', '\x02', '-1', 'b', '98', '.232818
72.23282192.232 82432.23282472. 23282592.232826 72.24029064.240 51224.canvas',
'2', '524', '412', '66')
6 23248088 <type 'tuple'('gc', 'types', 'isLargeItem', 'g', 'app',
'idDict', 'd', 'AttributeError ', 'new', 'get_objects', 'obj
', 'get', 'id', 'oldObj', 'None', 'keys', 'len', 'sort', 'n', 'key', 'type',
'repr')
7 23293152 <type 'tuple'(<_Pmw.P mw_1_2.lib.PmwB ase.__TkinterCa llWrapper
instance at 0x0175AB20>, '5780', '??', '??', '??', '66
', '4', '4522765', '??', '115', '174', '\x02', '-1', 'b', '98',
'.23281872.2328 2192.23282432.2 3282472.2328259 2.23282672.2402 9064.2
4051224.canvas' , '2', '524', '412', '66')
8 23562680 <type 'frame'<frame object at 0x016789B8>
9 24069264 <type 'list'[]
10 24116944 <type 'dict'{'stack': [], 'v': <vnode
27563632:'getNe wObjects'>}
11 24117936 <type 'list'['black', 'blue']
12 24118016 <type 'instancemethod '<bound method
__TkinterCallWr apper.__call__ of
<_Pmw.Pmw_1_2.l ib.PmwBase.__Tk interCallWrappe r
instance at 0x0295CA08>>
13 24953360 <type 'tuple'('type', 'obj', 'types', 'CodeType', 'ListType',
'len', 'TupleType', 'True', 'DictType', 'n', 'keys',
'key', 'get', 'val', 'repr', 'False')
14 24959216 <type 'tuple'(('comma nd', None), ('insert', None),
('overwrite', None), ('button', None), ('body', 'body'), ('text'
, 'head'), ('tree', 'head'), ('tree', 'canvas'), ('log', 'log'), ('text',
'log'), ('text', None), ('all', None))
15 25585536 <type 'tuple'('obj', 'd', 'oldObj', 'isLargeItem', 'n',
'keys', 'gc', 'key', 'new', 'types')
16 26717792 <type 'frame'<frame object at 0x0197AE60>
17 27405776 <type 'tupleiterator' <tupleiterato r object at 0x01A22DD0>
18 27405808 <class 'leoNodes.posit ion'<pos 27405808 lvl: 0 [0]
getNewObjects>
19 27405840 <class 'leoNodes.posit ion'<pos 27405840 lvl: 0 [0]
getNewObjects>
20 27405872 <class 'leoNodes.posit ion'<pos 27405872 lvl: 0 [0]
getNewObjects>
21 27405968 <class 'leoNodes.posit ion'<pos 27405968 [0] None>
22 27406000 <class 'leoNodes.posit ion'<pos 27406000 lvl: 0 [0] Startup>
23 27406032 <class 'leoNodes.posit ion'<pos 27406032 lvl: 0 [0]
Prototypes>
24 27406064 <class 'leoNodes.posit ion'<pos 27406064 lvl: 0 [0] Tests>
25 27406096 <class 'leoNodes.posit ion'<pos 27406096 lvl: 0 [0]
gc.get_objects>
26 27406128 <class 'leoNodes.posit ion'<pos 27406128 lvl: 0 [0] Java>
27 27406160 <class 'leoNodes.posit ion'<pos 27406160 lvl: 0 [0] gc tests>
28 27406192 <class 'leoNodes.posit ion'<pos 27406192 lvl: 0 [0] print sep>
29 27406224 <class 'leoNodes.posit ion'<pos 27406224 lvl: 0 [0]
print-plugins>
30 27406256 <class 'leoNodes.posit ion'<pos 27406256 lvl: 0 [0] byte-code
tests>
31 27406320 <class 'leoNodes.posit ion'<pos 27406320 lvl: 0 [0]
getNewObjects>
32 27564784 <class 'leoNodes.posit ion'<pos 27564784 lvl: 0 [0]
getNewObjects>
33 27571824 <type 'list'***** large item
34 27572704 <type 'list'['black', 'red', 'blue', 'purple']
35 27608960 <type 'dict'{'c': Commander 23254680:
u'C:\\prog\\tig ris-cvs\\leo\\test\ \test.leo', 'widget': <Tkinter.Canv as
insta
nce at 0x016EFF80>, 'actualEvent': <Tkinter.Even t instance at 0x0295C9B8>,
'char': '\x02', 'w': <Tkinter.Canv as instance at 0x016E
FF80>, 'y': 174, 'x': 115, 'keysym': 'b'}
36 27621536 <type 'dict'{'subst': None, 'widget': <Tkinter.Tk instance at
0x016055F8>, 'func': <function callit at 0x0296A030>}

37 27622976 <type 'dict'{}
38 27647312 <type 'tuple'(<functi on idleTimeHookHan dler at 0x00BBEAF0>,
(), <Tkinter.Tk instance at 0x016055F8>, ['24118016call
it'])
39 27647408 <type 'tuple'(None, 500, 0, 100, 1000)
40 27647456 <type 'tuple'('obj', 'val', 'keys', 'n', 'key')
41 43151120 <type 'frame'<frame object at 0x02926F10>
42 43368936 <type 'list'[]
43 43369296 <type 'list'[]
44 43369376 <type 'tuple'(<Tkinte r.Event instance at 0x0295C9B8>,)
45 43369496 <type 'list'[]
46 43369696 <type 'list'['24118016callit ']
47 43369736 <type 'list'[]
48 43369816 <type 'list'[]
49 43369856 <type 'list'[]
50 43369896 <type 'tuple'(leoTkTe xtWidget id: 25544304 name: head-6, 27)
51 43370096 <type 'tuple'(<pos 27406032 lvl: 0 [0] Prototypes>, 8)
52 43370216 <type 'tuple'('\x02', u'Ctrl+b')
53 43370296 <type 'instance'tkGui .leoKeyEvent: char: '\x02', keysym: 'b'
54 43370496 <type 'tuple'(<functi on masterBindKeyCa llback at 0x01756AF0>,
(<Tkinter.Even t instance at 0x0295C9B8>,))
55 43370616 <type 'list'[]
56 43370656 <type 'tuple'(leoTkTe xtWidget id: 27572864 name: head-10, 44)
57 43370696 <type 'tuple'(<pos 27406064 lvl: 0 [0] Tests>, 8)
58 43370776 <type 'tuple'(<pos 27406000 lvl: 0 [0] Startup>, 8)
59 43370856 <type 'tuple'(<pos 27406128 lvl: 0 [0] Java>, 8)
60 43370936 <type 'instance'<Tkin ter.Event instance at 0x0295C9B8>
61 43370976 <type 'list'[41, 46, 50, 51, 56, 1, 6, 11, 16, 21, 25, 29,
33]
62 43371016 <type 'instance'>
<_Pmw.Pmw_1_2.l ib.PmwBase.__Tk interCallWrappe r instance at 0x0295CA08>
63 43371056 <type 'list'[7, 12, 17, 42, 52]
64 43371096 <type 'list'[36, 40, 45, 49, 55, 5, 10, 15, 20, 24, 28]
65 43371136 <type 'list'[]
66 43371176 <type 'list'[34, 38, 43, 47, 53, 3, 8, 13, 18, 22, 26]
67 43371216 <type 'list'[]
68 43371256 <type 'list'[]
69 43371296 <type 'list'[]
70 43371336 <type 'list'[]
71 43371576 <type 'tuple'(leoTkTe xtWidget id: 25544784 name: head-8, 35)
72 43371696 <type 'list'[]
73 43371736 <type 'tuple'(<pos 27406192 lvl: 0 [0] print sep>, 8)
74 43372016 <type 'tuple'(leoTkTe xtWidget id: 25542984 name: head-2, 9)
75 43372136 <type 'list'[]
76 43372176 <type 'tuple'(leoTkTe xtWidget id: 27572984 name: head-11, 48)
77 43372376 <type 'tuple'(<pos 27406224 lvl: 0 [0] print-plugins>, 8)
78 43372592 <type 'dict'{'stack': [], 'v': <vnode
27563632:'getNe wObjects'>}
79 43372736 <type 'dict'{'keysym_ num': 98, 'widget': <Tkinter.Canv as
instance at 0x016EFF80>, 'x_root': 524, 'type': '2', 'delt
a': 66, 'y_root': 412, 'height': '??', 'char': '\x02', 'width': '??',
'state': 4, 'num': '??', 'time': 4522765, 'y': 174, 'x': 115
, 'serial': 5780, 'keysym': 'b', 'keycode': 66}
80 43373168 <type 'dict'{'2756324 8:5.': (leoTkTextWidge t id: 25543504
name: head-3, 14), '27563376:6.': (leoTkTextWidge t id: 25
544544 name: head-7, 31), '27563632:9.': (leoTkTextWidge t id: 27572424 name:
head-5, 23), '27563440:7.': (leoTkTextWidge t id: 2757
2024 name: head-1, 4), '25508048:0.': (leoTkTextWidge t id: 27572864 name:
head-10, 44), '27513232:2.': (leoTkTextWidge t id: 255447
84 name: head-8, 35), '27562704:3.': (leoTkTextWidge t id: 25542984 name:
head-2, 9), '27563152:4.': (leoTkTextWidge t id: 27572984
name: head-11, 48), '26446064:1.': (leoTkTextWidge t id: 25544304 name:
head-6, 27), '27563536:8.': (leoTkTextWidge t id: 25543704 n
ame: head-4, 19), '27563728:0.': (leoTkTextWidge t id: 27627608 name:
head-12, 54)}
81 43373312 <type 'dict'***** large item
82 43373456 <type 'dict'{'stack': [], 'v': None}
83 43373600 <type 'dict'{'stack': [], 'v': <vnode
27563632:'getNe wObjects'>}
84 43373744 <type 'dict'***** large item
85 43373888 <type 'dict'{'stack': [], 'v': <vnode
27563632:'getNe wObjects'>}
86 43374032 <type 'dict'{34: (<pos 27406000 lvl: 0 [0] Startup>, 8), 3:
(<pos 27406224 lvl: 0 [0] print-plugins>, 8), 38: (<pos
27406032 lvl: 0 [0] Prototypes>, 8), 8: (<pos 27406160 lvl: 0 [0] gc
tests>, 8), 43: (<pos 27406064 lvl: 0 [0] Tests>, 8), 13: (<
pos 27406256 lvl: 0 [0] byte-code tests>, 8), 47: (<pos 27406128 lvl: 0 [0]
Java>, 8), 18: (<pos 27406096 lvl: 0 [0] gc.get_object
s>, 8), 53: (<pos 27406192 lvl: 0 [0] print sep>, 8), 22: (<pos 27406320
lvl: 0 [0] getNewObjects>, 8), 26: (<pos 43384912 lvl: 1
[0] isLargeItem>, 8)}
87 43374176 <type 'dict'{'stack': [], 'v': <vnode 27513232:'Tests '>}
88 43374464 <type 'dict'{'stack': [], 'v': <vnode 25508048:'Start up'>}
89 43374608 <type 'dict'{'stack': [], 'v': <vnode 27562704:'Java' >}
90 43374752 <type 'dict'{'stack': [], 'v': <vnode 26446064:'Proto types'>}
91 43374896 <type 'dict'{'stack': [], 'v': <vnode 27563152:'print sep'>}
92 43375040 <type 'dict'{'stack': [], 'v': <vnode
27563248:'print-plugins'>}
93 43375184 <type 'dict'{'stack': [], 'v': <vnode 27563376:'gc tests'>}
94 43375328 <type 'dict'{'stack': [], 'v': <vnode 27563440:'byte-code
tests'>}
95 43375472 <type 'dict'{'stack': [], 'v': <vnode
27563536:'gc.ge t_objects'>}
96 43375616 <type 'dict'{'stack': [], 'v': <vnode
27563632:'getNe wObjects'>}
97 43376192 <type 'dict'{'stack': [], 'v': <vnode
27563728:'isLar geItem'>}
98 43380784 <type 'list'[]
99 43380824 <type 'tuple'(leoTkTe xtWidget id: 25543504 name: head-3, 14)
100 43381024 <type 'tuple'(<pos 27406160 lvl: 0 [0] gc tests>, 8)
101 43381184 <type 'list'[]
102 43381224 <type 'tuple'(leoTkTe xtWidget id: 25544544 name: head-7, 31)
103 43381424 <type 'tuple'(<pos 27406256 lvl: 0 [0] byte-code tests>, 8)
104 43381584 <type 'list'[]
105 43381624 <type 'tuple'(leoTkTe xtWidget id: 27572024 name: head-1, 4)
106 43381824 <type 'tuple'(<pos 27406096 lvl: 0 [0] gc.get_objects> , 8)
107 43382024 <type 'tuple'(leoTkTe xtWidget id: 25543704 name: head-4, 19)
108 43382224 <type 'tuple'(<pos 27406320 lvl: 0 [0] getNewObjects>, 8)
109 43382424 <type 'tuple'(<pos 43384912 lvl: 1 [0] isLargeItem>, 8)
110 43382704 <type 'tuple'(leoTkTe xtWidget id: 27572424 name: head-5, 23)
111 43382824 <type 'list'[]
112 43382864 <type 'tuple'(leoTkTe xtWidget id: 27627608 name: head-12, 54)
113 43383384 <type 'tuple'***** large item
114 43384912 <class 'leoNodes.posit ion'<pos 43384912 lvl: 1 [0]
isLargeItem>
115 43425840 <type 'function'<func tion callit at 0x0296A030>
116 43426032 <type 'function'<func tion isLargeItem at 0x0296A0F0>
117 43426224 <type 'tuple'(None, <code object isLargeItem at 0296A160,
file "C:\prog\ti gris-cvs\leo\test\sc riptFile.py", line 7>
, '----- %d new objects', 200, 0, 1, '%3d', '***** large item', '=====')
118 43442512 <type 'dict'***** large item
=====

I think this answers the question about where the strings are: they are
enclosed in tuples. My guess is that the tuples are the way that Python's
bytecode accesses the strings. For example, there is a LOAD_CONST i
bytecode whose argument i is an index into the stack frame (or is it the
code objects). Anyway, my guess is that strings seldom (never?) exist
outside the tuple by which they are referenced. So I think this answers the
mystery, mostly.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@chart er.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
May 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
5771
by: Ravi | last post by:
Hi, I have about 200GB of data that I need to go through and extract the common first part of a line. Something like this. >>>a = "abcdefghijklmnopqrstuvwxyz" >>>b = "abcdefghijklmnopBHLHT" >>>c = extract(a,b) >>>print c "abcdefghijklmnop"
2
1977
by: Nat | last post by:
Hi there, I have code as following but it returns error Error Type: Microsoft VBScript compilation (0x800A03F6) Expected 'End' /urbisjhdintranet/metadata/resultList.asp, line 324 which is the second last line at the end of the code. I have no idea where to put 'end'. It would be great if anyone could help. Thanks heaps! Nat
2
2491
by: Robert Zientara | last post by:
Sorry for asking stupid questions... I can't remember which settings in MS SQL define the behaviour of this comparison: select * from table where 'Anna ' = 'Anna' to be TRUE. Both strings are different because the first contains trailing blanks. How to change it to return FALSE what is my expected value?
13
2123
by: Thomas Zhu | last post by:
Hello, I know the difference between the two definations. But I do not know where are they in the memory. would someone tell me ? char s={"good", "morning"}; // at stack? char *t = {"good", "morning"}; // at heap? thanks in advance.
5
1297
by: Simon Harvey | last post by:
Hi everyone, As I understand it, storing an applications SQL Server connection string in the web.config file is a security risk. I'm wondering then, what the simplest solution is to this problem? Actually, my first question is, why is it a security risk? As I understand it, it is impossible to download the web.config file. Is this not the case? I've heard of a number of potential solutions to this problem - storing
5
1385
by: Darrel | last post by:
I've been taught that, at least in 1.1, you put your DB connection strings in the WebConfig file and access them from there as needed. In 2.0, it looks like I can do the same, but it's been suggested that I use the Web Site Admin Tool Wizard to store them. So, I have a few questions: Should I? The wizard itself says: "Do not store sensitive information, such as user names, passwords, or database connection strings in application...
2
22603
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be read (the file will be written by only this program); file can be either in text or binary (preferably binary as the files may be read repeatedly); the amount and size of strings in the array won't be known until run time (in the example I have it in...
0
80688
NeoPa
by: NeoPa | last post by:
Background Whenever code is used there must be a way to differentiate the actual code (which should be interpreted directly) with literal strings which should be interpreted as data. Numbers don't usually have this problem but Dates can too. Debug.Print Me.ControlName refers to a control on a form. Whereas, Debug.Print "Me.ControlName" simply prints the literal text Me.ControlName Where to Use Each Quote Type (' or ") In some places...
3
2469
by: crazy420fingers | last post by:
I'm running a python program that simulates a wireless network protocol for a certain number of "frames" (measure of time). I've observed the following: 1. The memory consumption of the program grows as the number of frames I simulate increases. To verify this, I've used two methods, which I invoke after every frame simulated:
0
8764
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9210
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9156
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6026
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4798
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.