python-attrs / cattrs

Composable custom class converters for attrs, dataclasses and friends.
https://catt.rs
MIT License
791 stars 110 forks source link

base64 pre-config option #552

Open AstraLuma opened 1 month ago

AstraLuma commented 1 month ago

Description

cattrs.preconf.json.make_converter() and cattrs.preconf.ujson.make_converter() use Base85.

While this is more efficient, it's bad for interop in the sense that base64 is much more common. (eg, both Browsers and Node have it built-in.) (Yes, Base85 code can be found for basically any language, but you can often assume that Base64 will be standard library.)

What I Did

try:
    from cattrs.preconf.ujson import make_converter
except ImportError:
    from cattrs.preconf.json import make_converter

converter = make_converter()
Tinche commented 1 month ago

Yeah I agree, if I could go back in time I'd have it be base64 by default. A configuration option for these converters sounds good.