Why cbor has been replaced by cbor2


from version 22.1.1 to 22.2.1, cbor serializer has been removed, replaced by cbor2.
why ?

cbor2 seems much lower than cbor, because it is implemented in pure python.


yes, previously, autobahn used both cbor and cbor2 for cbor handling in different places. we wanted to consolidate to one cbor implementation. also, cbor2 is more spec compliant in my experience, eg it supports decimals.

autobahn also supports proper and full round-trip and cross-trip serialization between JSON and CBOR, including binaries and decimals, and this also required cbor2

yes, on cpython it is slower than cbor, but on pypy, it is faster. so if you need speed, using pypy is the way to go.

hope this explanation makes sense,

1 Like

thanks tobias

the problem is that i monkey patch cbor in order to allow my developers to use transparently numpy arrays in wamp messages (pub/sub or call/callee).
So i have to do it again this for cbor2 :frowning:

ok, I see, sorry. from autobahn-python point of view, WAMP/Python is the API, and the CBOR library used internally isn’t a supported interface. but yeah, doesn’t help, I know …

however, there is a supported API for WAMP serializers

which you can use like

runner = ApplicationRunner(url=profile.network_url, realm=profile.network_realm, extra=extra, serializers=[CBORSerializer()])

hence, you could just copy-pasta the CBOR serializer, change to cbor from cbor2, and let your developers use your extended MyCBORSerializer …