I am passing a pickle object from a python softwar...
# announcements
b
I am passing a pickle object from a python software through a TCP socket and receiving it in my kotlin application. Does anyone know how I could unpickle it to retrieve my data ?
r
Could you unpickle it in Jython, which would make it a JVM object and so loadable in Kotlin? Something like this: https://nikoskatsanos.com/blog/2017/01/08/python-unpickling-in-java/
­čĹŹ 1
b
oh looks interesting. Thank you. I will have a look.
a
I'd recommend using another format than pickle as it's: A. specific to python, B. only safe to use if you can 100% trust the input C. changing the underlying code might cause it to no longer be unpickable (if producer/consumer drift or you upgrade and get an old pickle)
b
i control both ends so there won't be normally any inconsistencies between the python software and the kotlin application.
a
If the receiving end is never python, why not just use json?
b
actually I have to transfer json data and custom objects. One of those objects might be quite big (low frequency) so I am looking for a way that won't modify this object.
I can already send successfully strings, but this specific object (2D array of WORD) might take some time to be converted to string and then back to values in the kotlin application
a
Have you tried it? I'm not entirely sure I share the concern and since pickle isn't native to kotlin you'll still pay the price on that end. And if parsing the messages being sent back and forth is your bottleneck then maybe you should look at something like https://capnproto.org which specifically focuses on concerns like that
b
that's true.