cf-json / cf-json.github.io

Apache License 2.0
0 stars 2 forks source link

Support flattening `data` arrays? #12

Open aportagain opened 5 years ago

aportagain commented 5 years ago

Split out for further discussion from https://github.com/cf-json/cf-json.github.io/issues/10 , where @kwilcox originally asked whether we should add

3. Support for flattening the `data` arrays. The client is then responsible for reshaping to the defined variable shape

I'm pretty certain for our typical current cf-json use cases we'd very much prefer not to (have to) support this, and rather keep it simple, even if in some cases there may be a performance penalty.

aportagain commented 5 years ago

I just don't think the potential performance benefit would be worth the extra complexity for our use cases. I'm not much of a JavaScript person, but performance there seems to depend more on which JS engine is being used than on flat vs. nested? And also in that case typed arrays might be the way to go if you really care about performance? https://jsperf.com/2d-array-of-numbers/9 I did some very quick similar parsing tests in Python and they didn't really show much difference either, but of course your mileage may vary, no idea what "representative" sizes, number of dimensions, etc. we should assume...