gristlabs_grist-core/sandbox
Alex Hall fa6b57855e (core) Cache converting timestamp to date
Summary: Adds `@functools.lru_cache` to `ts_to_dt` and `ts_to_date` which are used in `_make_rich_value` in Date/DateTime columns, i.e. every time such a column is accessed in a formula. I noticed that these operations are surprisingly expensive while working on https://phab.getgrist.com/D4075. This is just an easy way to potentially significantly speed up certain docs and formulas.

Test Plan:
Put this code in an engine test case:

```
def test_(self):
  self.apply_user_action(["AddTable", "Table1", [
    {"id": "A", "type": "DateTime:America/Chicago"},
  ]])
  self.add_records("Table1", ["A"], [
    [i] for i in range(1000)
  ])
  formula = "for _ in range(1000): $A\nreturn 1"
  import time
  start = time.time()
  self.add_column(
    "Table1", formula, type="Any", isFormula=True, formula=formula
  )
  elapsed = time.time() - start
  print(f"Took {elapsed:.2f} for formula {formula}")
```

The time goes from ~10s to ~1s. Similar tests showed no noticeable slowdown when caching had no effect.

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D4099
2024-01-08 10:50:50 +02:00
..
docker (core) Upgrade to Python 3.11 2023-08-04 18:19:40 +02:00
grist (core) Cache converting timestamp to date 2024-01-08 10:50:50 +02:00
gvisor Check gvisor on startup of run.sh, and clean up scripts related to gvisor flags (#760) 2023-11-27 16:20:43 -05:00
pyodide bump pyodide version number (#735) 2023-11-09 13:21:06 -05:00
bundle_as_wheel.sh support other SQLite wrappers, and various hooks needed by grist-static (#516) 2023-05-23 15:17:28 -04:00
gen_js_schema.py add a script for copying schema information from python to typescript 2023-01-17 15:54:41 -05:00
install_tz.js (core) apply some dependabot suggestions 2022-09-07 14:15:34 -04:00
MANIFEST.in support other SQLite wrappers, and various hooks needed by grist-static (#516) 2023-05-23 15:17:28 -04:00
requirements3.in (core) Upgrade to Python 3.11 2023-08-04 18:19:40 +02:00
requirements3.txt (core) Fix updating attributes inside f-strings when columns are renamed 2023-09-11 14:41:30 +02:00
requirements.txt (core) Fix updating attributes inside f-strings when columns are renamed 2023-09-11 14:41:30 +02:00
run.sh Check gvisor on startup of run.sh, and clean up scripts related to gvisor flags (#760) 2023-11-27 16:20:43 -05:00
setup.py support other SQLite wrappers, and various hooks needed by grist-static (#516) 2023-05-23 15:17:28 -04:00
watch.sh Add command to debug the server (#533) 2023-06-20 12:49:57 -04:00