Re: RFC Idea - is_json - looking for feedback

From: Date: Mon, 01 Aug 2022 05:19:17 +0000
Subject: Re: RFC Idea - is_json - looking for feedback
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-118335@lists.php.net to get a copy of this message
On Sun, Jul 31, 2022 at 11:23 AM juan carlos morales < dev.juan.morales@gmail.com> wrote: > ----- Benchmark including memory_get_peak_usage ----- > > # json_decode() > > Megas used before call: 79.23828125 > PEAK Megas used before call: 128.00390625 //<---- > Megas used after call: 3269.23828125 > PEAK Megas used after call: 3309.23828125 //<---- > Difference: 3190 > PEAK Difference: 3181.234375 //<----- > Time: 12.109144926071 seconds > > # is_json() > > Megas used before call: 79.23828125 > PEAK Megas used before call: 128.00390625 //<---- > Megas used after call: 79.23828125 > PEAK Megas used after call: 128.00390625 //<---- > Difference: 0 > PEAK Difference: 0 //<----- > Time: 5.4504480361938 seconds > This is actually suggesting a compelling case to me if this held up under close inspection of the code. You've certainly shown that it solves a problem that userspace is sort of half-solving, due to the limitations of the language around memory. > I want to clarify, as I previously mentioned, I did not develop any parser > at all, the parser already exists in PHP and is use by json_decode(), in > short words , what I propose is to create a new function, as an interface > to THE EXISTING PARSER, only, and only, to check if a string is a valid > json-string or not. > This is curious... the existing parser *should* need to allocate the memory. This makes me wonder if the above performance would hold up under scrutiny, *but* you have fully convinced me at the point (not that I have a vote) that it's worth the RFC to explore it. > Regarding publishing the a PR with my implementation, is out of context at > the moment, because we are discussing if a functionality like this should > be included or not, and nothing else. Also I am pretty sure that if this > gets a YES from the community (so far seems so), and I show my > implementation, someone will tell me that it could be done in a different > way , and is totally fine, is great actually. But now, at this moment, > everything is about the functionality. > Ah, okay. That I understand, even if I find it a tad frustrating. You want to understand if people are on-board with the merits of the idea without it being attached to your particular proof-of-concept code. If I'm reading the feedback correctly though, I think that any votes the RFC received would be heavily dependent on the eventual implementation and its performance though. So I think the RFC will be pretty closely tied to an implementation regardless of your efforts. Jordan

« previous php.internals (#118335) next »