Disk icon indicating copy to clipboard operation
Disk copied to clipboard

Using alternates besides JSONDecoder for deserialization

Open michaeleisel opened this issue 6 years ago • 6 comments

ZippyJSON (a framework that I created), is a 3-4x faster version of JSONDecoder. Using it could be a big speed boost for consumers. However, the customization provided by https://github.com/saoudrizwan/Disk/pull/28 doesn't allow for anything besides JSONDecoder (or a subclass of it). This makes it difficult to use ZippyJSON because alternate implementations are best not to subclass it to ensure good performance. Here are some possibilities:

  • Allow users to pass in anything that implements TopLevelDecoder, and not just JSONDecoder
  • Mention performance wins from using a custom implementation like ZippyJSON
  • Simply use ZippyJSON behind the scenes by default

michaeleisel avatar Sep 16 '19 23:09 michaeleisel

To be clear, a well-written binary decoder/encoder would be faster, but I don't know if one exists right now (e.g. a fast MessagePack encoder/decoder)

michaeleisel avatar Sep 17 '19 01:09 michaeleisel

This would be cool! I've been keeping an eye on ZippyJSON for a while. Being able to speedup Disk reads as well would be a serious +1 for switching.

RamblinWreck77 avatar Oct 29 '19 14:10 RamblinWreck77

Yeah, I'm interested in using https://github.com/christophhagen/BinaryCodable for larger file writes.

idolize avatar Jan 09 '24 23:01 idolize

FYI for those interested - I made a fork here that allows you to conform any custom encoder/decoder to the DiskEncoder or DiskDecoder protocols and use those instead with any of the built in Disk functions.

idolize avatar Feb 14 '24 21:02 idolize

What about the TopLevelDecoder protocol, can we leverage that here

michaeleisel avatar Mar 01 '24 00:03 michaeleisel

@michaeleisel it's probably possible, but I had issues getting the compiler happy when I tried (admittedly I didn't spent a lot of time on it)

idolize avatar Mar 01 '24 02:03 idolize