Repository navigation
Conversation
|
Thanks for this @russlan23, and welcome — this is a clean, well-validated first contribution. To be clear up front: the change does exactly what #926 asked for at the time you wrote it, right down to the diff the issue prescribed, and the validation you did (native vs simulated-Emscripten compiled target, plus the The background is #702, an old PR to optimise The reason I don't want to merge this as an interim step is that the gate leaves browser users on a serial O(n²) path, and that's the environment where it hurts most. Measured natively (numba 0.62.1, numpy 2.3.5, Pareto(3) inputs), comparing what the gate compiles to on Emscripten against the rewrite:
Those serial figures are native timings; WASM typically runs a further 2–3x slower, so a 100,000-element Gini in JupyterLite would be a 20–30 second call. It wouldn't crash, which is what this PR set out to fix, but it wouldn't really be usable either. The rewrite gets it to single-digit milliseconds and needs no platform branch at all. If you'd like to take the rewrite, it would be very welcome — it's the same file and the same issue, #926 now carries the formula and acceptance criteria, and you clearly have the setup for validating it. No obligation at all if you'd rather pick up something else; there are other open items under the #925 umbrella. Either way, thanks for jumping on this one so quickly. |
Closes #926
Summary
gini_coefficienton Emscripten;The browser Numba runtime is single-threaded and cannot compile this library's only
@njit(parallel=True)function. Selecting the decorator option fromsys.platformletsprangeuse its serial semantics in JupyterLite without changing the public API or native behavior.Validation
python -m pytest -q quantecon/tests/test_inequality.py— 4 passedpython -m flake8 --select=F401,F405,E231 quantecon— passedparallel=Trueparallel=False;gini_coefficient([1, 2, 3]) == 2/9git diff --check— passedAutomated assistance was used to prepare and validate this change.