Mercurial > cpython-lru_cache-weakref
diff Python/marshal.c @ 1288:9fed5726a36d legacy-trunk
Several changes in one:
(1) dictionaries/mappings now have attributes values() and items() as
well as keys(); at the C level, use the new function mappinggetnext()
to iterate over a dictionary.
(2) "class C(): ..." is now illegal; you must write "class C: ...".
(3) Class objects now know their own name (finally!); and minor
improvements to the way how classes, functions and methods are
represented as strings.
(4) Added an "access" statement and semantics. (This is still
experimental -- as long as you don't use the keyword 'access' nothing
should be changed.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 19 May 1993 14:50:45 +0000 |
| parents | 14369a5e6167 |
| children | cd397266dc1c |
line wrap: on
line diff
--- a/Python/marshal.c Mon May 17 08:34:16 1993 +0000 +++ b/Python/marshal.c Wed May 19 14:50:45 1993 +0000 @@ -174,17 +174,14 @@ } } else if (is_dictobject(v)) { + int pos; + object *key, *value; w_byte(TYPE_DICT, p); /* This one is NULL object terminated! */ - n = getdictsize(v); - for (i = 0; i < n; i++) { - object *key, *val; - key = getdict2key(v, (int)i); - if (key != NULL) { - val = dict2lookup(v, key); /* Can't be NULL */ - w_object(key, p); - w_object(val, p); - } + pos = 0; + while (mappinggetnext(v, &pos, &key, &value)) { + w_object(key, p); + w_object(value, p); } w_object((object *)NULL, p); }
