mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Fixup set/dict interoperability.
This commit is contained in:
parent
cbac8ce5b0
commit
15cade0568
1 changed files with 11 additions and 0 deletions
|
|
@ -919,7 +919,18 @@ set_update_internal(PySetObject *so, PyObject *other)
|
||||||
PyObject *value;
|
PyObject *value;
|
||||||
Py_ssize_t pos = 0;
|
Py_ssize_t pos = 0;
|
||||||
long hash;
|
long hash;
|
||||||
|
Py_ssize_t dictsize = PyDict_Size(other);
|
||||||
|
|
||||||
|
/* Do one big resize at the start, rather than
|
||||||
|
* incrementally resizing as we insert new keys. Expect
|
||||||
|
* that there will be no (or few) overlapping keys.
|
||||||
|
*/
|
||||||
|
if (dictsize == -1)
|
||||||
|
return -1;
|
||||||
|
if ((so->fill + dictsize)*3 >= (so->mask+1)*2) {
|
||||||
|
if (set_table_resize(so, (so->used + dictsize)*2) != 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
while (_PyDict_Next(other, &pos, &key, &value, &hash)) {
|
while (_PyDict_Next(other, &pos, &key, &value, &hash)) {
|
||||||
setentry an_entry;
|
setentry an_entry;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue