MCPcopy Index your code
hub / github.com/python/cpython / test_sizeof_exact

Method test_sizeof_exact

Lib/test/test_ordered_dict.py:893–923  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

891
892 @support.cpython_only
893 def test_sizeof_exact(self):
894 OrderedDict = self.OrderedDict
895 calcsize = struct.calcsize
896 size = support.calcobjsize
897 check = self.check_sizeof
898
899 basicsize = size('nQ2P' + '3PnPn2P')
900 keysize = calcsize('n2BI2n')
901
902 entrysize = calcsize('n2P')
903 p = calcsize('P')
904 nodesize = calcsize('Pn2P')
905
906 od = OrderedDict()
907 check(od, basicsize) # 8byte indices + 8*2//3 * entry table
908 od.x = 1
909 check(od, basicsize)
910 od.update([(i, i) for i in range(3)])
911 check(od, basicsize + keysize + 8*p + 8 + 5*entrysize + 3*nodesize)
912 od.update([(i, i) for i in range(3, 10)])
913 check(od, basicsize + keysize + 16*p + 16 + 10*entrysize + 10*nodesize)
914
915 check(od.keys(), size('P'))
916 check(od.items(), size('P'))
917 check(od.values(), size('P'))
918
919 itersize = size('iP2n2P')
920 check(iter(od), itersize)
921 check(iter(od.keys()), itersize)
922 check(iter(od.items()), itersize)
923 check(iter(od.values()), itersize)
924
925 def test_key_change_during_iteration(self):
926 OrderedDict = self.OrderedDict

Callers

nothing calls this directly

Calls 6

keysMethod · 0.95
itemsMethod · 0.95
valuesMethod · 0.95
OrderedDictClass · 0.70
checkFunction · 0.70
updateMethod · 0.45

Tested by

no test coverage detected