Issue #191: beancount.core.Inventory should be a dict when Costs have dates (blais/beancount)

17 views
Skip to first unread message

Jason Chu

unread,
Sep 10, 2017, 11:29:08 PM9/10/17
to bean...@googlegroups.com
New issue 191: beancount.core.Inventory should be a dict when Costs have dates
https://bitbucket.org/blais/beancount/issues/191/beancountcoreinventory-should-be-a-dict

Jason Chu:

The claim in https://bitbucket.org/blais/beancount/src/621cec5ed38bcd128a3502a3b5c367f283deffe2/beancount/core/inventory.py?at=default&fileviewer=file-view-default#inventory.py-58 doesn't hold up anymore. Any account where you buy small amounts of a commodity will expand the list of positions indefinitely because each Cost object will be unique.

Most of the computational pain happens in add_amount (https://bitbucket.org/blais/beancount/src/621cec5ed38bcd128a3502a3b5c367f283deffe2/beancount/core/inventory.py?at=default&fileviewer=file-view-default#inventory.py-365) when iterating over a list of positions that usually don't match (unless reducing).

I have a hack that proves it too. The original code (when rendering the fava balance sheet) takes about 3 seconds to render net worth and a balance tree, with the hack applied it takes about 2 seconds.


Reply all
Reply to author
Forward
0 new messages