Live data from Hacker News

I made JSON.parse() 2x faster

radex.io

11–15 of 15 posts

Re: I made JSON.parse() 2x faster

#11

This is delightful! Maybe next you can make the object spread operator faster ;). I was recently bitten by it in a hot loop, thinking it was generally syntactic sugar. Turns out that if I know all the property names in an object, it’s far far faster to just assign them all manually.

Doesn’t assigning properties behave differently? Spread creates a new object while assigning reuses the existing. Unless you mean creating a new object and then assigning the properties. I’d be surprised if that performed worse though. Also curious if the properties are primitives?

Re: I made JSON.parse() 2x faster

#13
See, this is the difference between a productive engineer and a purist.

You are a productive engineer. You see a fast library that needs a different encoding, so your first thought is to add a transcoding step and make a 2x gain in a short timeframe.

I am a purist. I see a fast library that needs a different encoding, and my first thought is “ok, I’ll fork that library and make it work with UTF-16 natively”. 24 months later I’ll be found, bearded down to my kneecaps, staring at the bottom of a bottle of scotch, mumbling a mixture of curse words and “PowerPC”. But Id get a 2.05x speedup eventually, so…

Re: I made JSON.parse() 2x faster

#14

This is delightful! Maybe next you can make the object spread operator faster ;). I was recently bitten by it in a hot loop, thinking it was generally syntactic sugar. Turns out that if I know all the property names in an object, it’s far far faster to just assign them all manually.

I wonder if you can just configure this as part of the compile step with typescript, when the object you're spreading has a known type

Re: I made JSON.parse() 2x faster

#15

See, this is the difference between a productive engineer and a purist. You are a productive engineer. You see a fast library that needs a different encoding, so your first thought is to add a transcoding step and make a 2x gain in a short timeframe. I am a purist. I see a fast library that needs a different encoding, and my first thought is “ok, I’ll fork that library and make it work with UTF-16 natively”. 24 month…

Thanks for the chuckle :D And of course you use nixos :]
Post reply on HN