Go back to `tomllib` for ledger loading, it's wayy faster
parent
97b2b25256
commit
a1a10676cd
|
@ -35,6 +35,7 @@ from pendulum import (
|
||||||
parse,
|
parse,
|
||||||
)
|
)
|
||||||
import tomlkit
|
import tomlkit
|
||||||
|
import tomli
|
||||||
|
|
||||||
from .. import config
|
from .. import config
|
||||||
from ..data.types import Struct
|
from ..data.types import Struct
|
||||||
|
@ -141,8 +142,10 @@ class TransactionLedger(UserDict):
|
||||||
if fqme:
|
if fqme:
|
||||||
txdict['fqme'] = fqme
|
txdict['fqme'] = fqme
|
||||||
|
|
||||||
|
print(f'WRITING LEDGER {self.file_path}')
|
||||||
with self.file_path.open(mode='w') as fp:
|
with self.file_path.open(mode='w') as fp:
|
||||||
tomlkit.dump(towrite, fp)
|
tomlkit.dump(towrite, fp)
|
||||||
|
print(f'FINISHED WRITING LEDGER {self.file_path}')
|
||||||
|
|
||||||
def update_from_t(
|
def update_from_t(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -345,7 +345,7 @@ def load_ledger(
|
||||||
|
|
||||||
with fpath.open(mode='rb') as cf:
|
with fpath.open(mode='rb') as cf:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
ledger_dict = tomlkit.parse(cf.read())
|
ledger_dict = tomllib.load(cf)
|
||||||
log.debug(f'Ledger load took {time.time() - start}s')
|
log.debug(f'Ledger load took {time.time() - start}s')
|
||||||
|
|
||||||
return ledger_dict, fpath
|
return ledger_dict, fpath
|
||||||
|
|
Loading…
Reference in New Issue