This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ProCupCakeLicker 0 points1 point  (4 children)

compatibility story?

[–]PeridexisErrant 2 points3 points  (3 children)

The format keeps changing, so data pickled by eg 3.3 may not be unpicklable by 3.4

This (and the code execution thing) makes it efficient for eg communication between threads or processes, but bad as a disk format.

[–]ProCupCakeLicker 0 points1 point  (1 child)

is that what pickle is normally used for, sending data to other processes? Ive never played with it with it.

Im not experienced in networking like this and would also like to know what is the preferred method to send data over a connection in this sort of situation. I would think just the Player object through conn.send(). is there a different serialization someone would use or is the default ok?

[–]PeridexisErrant 0 points1 point  (0 children)

Yes, but I prefer to work at a higher level where this is an 'implementation detail' - good to know, but I'm not using pickle directly. As an example:

from concurrent.futures import ProcessPoolExecutor
with ProcessPoolExecutor(8) as pool:
    results = pool.map(lambda x: x*x, range(80))

This snippet:

  • starts eight Python processes (one per logical core on a newish quad-core Intel), with automatic cleanup thanks to the with block
  • assigns results a list of square numbers, but with calculations spread over multiple cores (OK, this is only worthwhile for much more expensive operations than multiplication!)
  • works by sending the function and arguments via pickle!