Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
60b29961
Commit
60b29961
authored
Jan 01, 2006
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed English in a comment; trimmed trailing whitespace;
no code changes.
parent
0cdc3d88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
Objects/dictobject.c
Objects/dictobject.c
+11
-11
No files found.
Objects/dictobject.c
View file @
60b29961
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
/* Dictionary object implementation using a hash table */
/* Dictionary object implementation using a hash table */
/* The distribution includes a separate file, Objects/dictnotes.txt,
/* The distribution includes a separate file, Objects/dictnotes.txt,
describing explorations into dictionary design and optimization.
describing explorations into dictionary design and optimization.
It covers typical dictionary use patterns, the parameters for
It covers typical dictionary use patterns, the parameters for
tuning dictionaries, and several ideas for possible optimizations.
tuning dictionaries, and several ideas for possible optimizations.
*/
*/
...
@@ -519,10 +519,10 @@ PyDict_GetItem(PyObject *op, PyObject *key)
...
@@ -519,10 +519,10 @@ PyDict_GetItem(PyObject *op, PyObject *key)
}
}
/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the
/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the
* dictionary if it
i
s merely replacing the value for an existing key.
* dictionary if it
'
s merely replacing the value for an existing key.
* This
is means that it's safe to loop over a dictionary with
* This
means that it's safe to loop over a dictionary with PyDict_Next()
*
PyDict_Next() and occasionally replace a value -- but you can't
*
and occasionally replace a value -- but you can't insert new keys or
*
insert new keys or
remove them.
* remove them.
*/
*/
int
int
PyDict_SetItem
(
register
PyObject
*
op
,
PyObject
*
key
,
PyObject
*
value
)
PyDict_SetItem
(
register
PyObject
*
op
,
PyObject
*
key
,
PyObject
*
value
)
...
@@ -554,15 +554,15 @@ PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value)
...
@@ -554,15 +554,15 @@ PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value)
/* If we added a key, we can safely resize. Otherwise just return!
/* If we added a key, we can safely resize. Otherwise just return!
* If fill >= 2/3 size, adjust size. Normally, this doubles or
* If fill >= 2/3 size, adjust size. Normally, this doubles or
* quaduples the size, but it's also possible for the dict to shrink
* quaduples the size, but it's also possible for the dict to shrink
* (if ma_fill is much larger than ma_used, meaning a lot of dict
* (if ma_fill is much larger than ma_used, meaning a lot of dict
* keys have been * deleted).
* keys have been * deleted).
*
*
* Quadrupling the size improves average dictionary sparseness
* Quadrupling the size improves average dictionary sparseness
* (reducing collisions) at the cost of some memory and iteration
* (reducing collisions) at the cost of some memory and iteration
* speed (which loops over every possible entry). It also halves
* speed (which loops over every possible entry). It also halves
* the number of expensive resize operations in a growing dictionary.
* the number of expensive resize operations in a growing dictionary.
*
*
* Very large dictionaries (over 50K items) use doubling instead.
* Very large dictionaries (over 50K items) use doubling instead.
* This may help applications with severe memory constraints.
* This may help applications with severe memory constraints.
*/
*/
if
(
!
(
mp
->
ma_used
>
n_used
&&
mp
->
ma_fill
*
3
>=
(
mp
->
ma_mask
+
1
)
*
2
))
if
(
!
(
mp
->
ma_used
>
n_used
&&
mp
->
ma_fill
*
3
>=
(
mp
->
ma_mask
+
1
)
*
2
))
...
@@ -734,7 +734,7 @@ dict_dealloc(register dictobject *mp)
...
@@ -734,7 +734,7 @@ dict_dealloc(register dictobject *mp)
PyMem_DEL
(
mp
->
ma_table
);
PyMem_DEL
(
mp
->
ma_table
);
if
(
num_free_dicts
<
MAXFREEDICTS
&&
mp
->
ob_type
==
&
PyDict_Type
)
if
(
num_free_dicts
<
MAXFREEDICTS
&&
mp
->
ob_type
==
&
PyDict_Type
)
free_dicts
[
num_free_dicts
++
]
=
mp
;
free_dicts
[
num_free_dicts
++
]
=
mp
;
else
else
mp
->
ob_type
->
tp_free
((
PyObject
*
)
mp
);
mp
->
ob_type
->
tp_free
((
PyObject
*
)
mp
);
Py_TRASHCAN_SAFE_END
(
mp
)
Py_TRASHCAN_SAFE_END
(
mp
)
}
}
...
@@ -2251,7 +2251,7 @@ static PyObject *dictiter_iternextitem(dictiterobject *di)
...
@@ -2251,7 +2251,7 @@ static PyObject *dictiter_iternextitem(dictiterobject *di)
Py_DECREF
(
PyTuple_GET_ITEM
(
result
,
1
));
Py_DECREF
(
PyTuple_GET_ITEM
(
result
,
1
));
}
else
{
}
else
{
result
=
PyTuple_New
(
2
);
result
=
PyTuple_New
(
2
);
if
(
result
==
NULL
)
if
(
result
==
NULL
)
return
NULL
;
return
NULL
;
}
}
di
->
len
--
;
di
->
len
--
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment