octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternati


From: Philip Nienhuis
Subject: [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json
Date: Tue, 28 Dec 2021 10:34:35 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0

Follow-up Comment #57, patch #9980 (project octave):

Comparing fromJSON_v2_7_3 & jsondecode:

>> fid = fopen ('numerical.json')';
>> js = fread (fid, Inf, "*char")';
>> fclose (fid);
>> tic; out1 = fromJSON_v2_7_3 (js); toc
Elapsed time is 5.74516 seconds.
>> tic; out2 = jsondecode (js); toc
Elapsed time is 0.167249 seconds.
>> whos
Variables visible from the current scope:

variables in scope: top scope

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         ans         1x1                          8  double
         fid         1x1                          8  double
         js          1x18787793            18787793  char
         out1        1x1                    8016000  struct
         out2        1x1                    8016000  struct

Total is 18787797 elements using 34819809 bytes


... so I infer fromJSON (v.2.7.3) and jsondecode produce the same output
(didn't check  in detail; though a cursory inspection in the variable editor
shows they aren't complicated data structures).

What I did next:
run both files through dos2unix to change CRLF EOLs into LF EOLs; adapted
fromJSON's & toJSON's Texinfo a bit to better comply with Octave conventions
(the very first sentence, not a paragraph, is merely meant to concisively
describe what the function does) and esp. in fromJSON I've collected all info
on SARRAY into the second input argument description. Also I fixed some
scattered typos, and the results + diffs compared to your latest versions are
attached.  In those diffs you'll be interested mostly in the Texinfo; I didn't
touch the rest except for removing trailing whitespace.

What I still want to do is morph the info in the "Updates" section below the
Texinfo into the commit message, that'll hopefully shorten the code while your
work is still documented in the Mercurial log.
Of course, all of this if you agree :-)
One last remark: Would you mind if I change all comment line starts from '%'
into '##' (or '#' when comments follow statements on the same line)? Both
functions can't run in Matlab anyaway (if only for the texinfo header) and
that way the io package code is more Octave style compliant  - an aim of me as
package maintainer.

Whatever, I'm impressed with your work, Ketan, thank you very much.

(file #52576, file #52577, file #52578, file #52579)
    _______________________________________________________

Additional Item Attachment:

File name: fromJSON.m                     Size:35 KB
    <https://file.savannah.gnu.org/file/fromJSON.m?file_id=52576>

File name: toJSON.m                       Size:17 KB
    <https://file.savannah.gnu.org/file/toJSON.m?file_id=52577>

File name: fromJSON.diff                  Size:23 KB
    <https://file.savannah.gnu.org/file/fromJSON.diff?file_id=52578>

File name: toJSON.diff                    Size:3 KB
    <https://file.savannah.gnu.org/file/toJSON.diff?file_id=52579>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/patch/?9980>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]