Skip to content

Commit

Permalink
Merge pull request #218 from kkpattern/preallocate_precord_map
Browse files Browse the repository at this point in the history
Preallocate pmap according to PRecord fields count
  • Loading branch information
tobgu authored Jun 5, 2021
2 parents be23bac + 79ba001 commit 97c6309
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyrsistent/_pmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def pmap(initial={}, pre_size=0):
>>> pmap({'a': 13, 'b': 14})
pmap({'b': 14, 'a': 13})
"""
if not initial:
if not initial and pre_size == 0:
return _EMPTY_PMAP

return _turbo_mapping(initial, pre_size)
Expand Down
2 changes: 1 addition & 1 deletion pyrsistent/_precord.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __new__(cls, **kwargs):
for k, v in cls._precord_initial_values.items())
initial_values.update(kwargs)

e = _PRecordEvolver(cls, pmap(), _factory_fields=factory_fields, _ignore_extra=ignore_extra)
e = _PRecordEvolver(cls, pmap(pre_size=len(cls._precord_fields)), _factory_fields=factory_fields, _ignore_extra=ignore_extra)
for k, v in initial_values.items():
e[k] = v

Expand Down

0 comments on commit 97c6309

Please sign in to comment.