mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
Update py_dict.c
This commit is contained in:
parent
05e0432b4e
commit
94d8a40653
@ -251,7 +251,7 @@ static bool Dict__set(Dict* self, py_TValue* key, py_TValue* val) {
|
|||||||
self->length++;
|
self->length++;
|
||||||
// check if we need to rehash
|
// check if we need to rehash
|
||||||
float load_factor = (float)self->length / self->capacity;
|
float load_factor = (float)self->length / self->capacity;
|
||||||
if(load_factor > 0.572) Dict__rehash_2x(self);
|
if(load_factor > 0.3) Dict__rehash_2x(self);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,13 +338,13 @@ static bool dict__new__(int argc, py_Ref argv) {
|
|||||||
py_Type cls = py_totype(argv);
|
py_Type cls = py_totype(argv);
|
||||||
int slots = cls == tp_dict ? 0 : -1;
|
int slots = cls == tp_dict ? 0 : -1;
|
||||||
Dict* ud = py_newobject(py_retval(), cls, slots, sizeof(Dict));
|
Dict* ud = py_newobject(py_retval(), cls, slots, sizeof(Dict));
|
||||||
Dict__ctor(ud, 7, 4);
|
Dict__ctor(ud, 17, 4);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void py_newdict(py_OutRef out) {
|
void py_newdict(py_OutRef out) {
|
||||||
Dict* ud = py_newobject(out, tp_dict, 0, sizeof(Dict));
|
Dict* ud = py_newobject(out, tp_dict, 0, sizeof(Dict));
|
||||||
Dict__ctor(ud, 7, 4);
|
Dict__ctor(ud, 17, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dict__init__(int argc, py_Ref argv) {
|
static bool dict__init__(int argc, py_Ref argv) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user