-2

I want to send a python class from one computer to the other. In order to send data, it must be in byte form. I know I can do this with dictionaries, but I was wondering if there is a way to convert a class into bytes? I'd prefer to use something other than pickle, because I need something that is fast and efficient.

Thanks

CircuitSacul
  • 1,594
  • 12
  • 32

1 Answers1

1

You should take a look at pickle or jsonpickle. Those are the simplest libraries for Python serialization.

Tihran
  • 106
  • 4
  • I am creating a game, and I need something that is fast and efficient. Pickling is slow, what about jsonpickle? – CircuitSacul May 25 '20 at 12:56
  • 1
    @LD it should be even slower. You are doing a network game replication, right? So you need to transfer data, like, every game frame? Then I would suggest creating a manual serialization when you gather only the most important data. Yes, it is a lot of work, but I think this is the only way to do it as fast as possible in Python. – Tihran May 25 '20 at 12:58
  • Ok, I will probably stick to using dictionaries then. Thanks – CircuitSacul May 25 '20 at 13:00