|
2 | 2 | /* Dictionary object implementation using a hash table */ |
3 | 3 |
|
4 | 4 | /* The distribution includes a separate file, Objects/dictnotes.txt, |
5 | | - describing explorations into dictionary design and optimization. |
| 5 | + describing explorations into dictionary design and optimization. |
6 | 6 | It covers typical dictionary use patterns, the parameters for |
7 | 7 | tuning dictionaries, and several ideas for possible optimizations. |
8 | 8 | */ |
@@ -519,10 +519,10 @@ PyDict_GetItem(PyObject *op, PyObject *key) |
519 | 519 | } |
520 | 520 |
|
521 | 521 | /* CAUTION: PyDict_SetItem() must guarantee that it won't resize the |
522 | | - * dictionary if it is merely replacing the value for an existing key. |
523 | | - * This is means that it's safe to loop over a dictionary with |
524 | | - * PyDict_Next() and occasionally replace a value -- but you can't |
525 | | - * insert new keys or remove them. |
| 522 | + * dictionary if it's merely replacing the value for an existing key. |
| 523 | + * This means that it's safe to loop over a dictionary with PyDict_Next() |
| 524 | + * and occasionally replace a value -- but you can't insert new keys or |
| 525 | + * remove them. |
526 | 526 | */ |
527 | 527 | int |
528 | 528 | PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) |
@@ -554,15 +554,15 @@ PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) |
554 | 554 | /* If we added a key, we can safely resize. Otherwise just return! |
555 | 555 | * If fill >= 2/3 size, adjust size. Normally, this doubles or |
556 | 556 | * quaduples the size, but it's also possible for the dict to shrink |
557 | | - * (if ma_fill is much larger than ma_used, meaning a lot of dict |
| 557 | + * (if ma_fill is much larger than ma_used, meaning a lot of dict |
558 | 558 | * keys have been * deleted). |
559 | | - * |
| 559 | + * |
560 | 560 | * Quadrupling the size improves average dictionary sparseness |
561 | 561 | * (reducing collisions) at the cost of some memory and iteration |
562 | 562 | * speed (which loops over every possible entry). It also halves |
563 | 563 | * the number of expensive resize operations in a growing dictionary. |
564 | | - * |
565 | | - * Very large dictionaries (over 50K items) use doubling instead. |
| 564 | + * |
| 565 | + * Very large dictionaries (over 50K items) use doubling instead. |
566 | 566 | * This may help applications with severe memory constraints. |
567 | 567 | */ |
568 | 568 | 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 | 734 | PyMem_DEL(mp->ma_table); |
735 | 735 | if (num_free_dicts < MAXFREEDICTS && mp->ob_type == &PyDict_Type) |
736 | 736 | free_dicts[num_free_dicts++] = mp; |
737 | | - else |
| 737 | + else |
738 | 738 | mp->ob_type->tp_free((PyObject *)mp); |
739 | 739 | Py_TRASHCAN_SAFE_END(mp) |
740 | 740 | } |
@@ -2251,7 +2251,7 @@ static PyObject *dictiter_iternextitem(dictiterobject *di) |
2251 | 2251 | Py_DECREF(PyTuple_GET_ITEM(result, 1)); |
2252 | 2252 | } else { |
2253 | 2253 | result = PyTuple_New(2); |
2254 | | - if (result == NULL) |
| 2254 | + if (result == NULL) |
2255 | 2255 | return NULL; |
2256 | 2256 | } |
2257 | 2257 | di->len--; |
|
0 commit comments