Python Forum
pickle docs say bytes in one place, strings in another
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pickle docs say bytes in one place, strings in another
#1
for pickle documentation i read "The pickle and marshal modules can turn many Python data types into a stream of bytes and then recreate the objects from the bytes." and '“Pickling” is the process whereby a Python object hierarchy is converted into a byte stream, and “unpickling” is the inverse operation, whereby a byte stream is converted back into an object hierarchy.' and i also read "file must have a write() method that accepts a single string argument."

which can i use, bytes and/or strings?

i want to send picked data to a subprocess over a pipe, but the pipe wants data only in bytes. do i need to encode it before sending it? is there a way to send it over the pipe, directly?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
I supspect the pickle documentation may be using the word 'string' to mean a string of bytes. For example one finds this example in the documentation
class Foo:
    attr = 'A class attribute'

picklestring = pickle.dumps(Foo)
but pickle.dumps() returns bytes, not str.
Reply
#3
they need to establish a consistency standard in the official documentation to have some particular expression that identifies each type, distinctly and perceptibly. for example "string of bytes".
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 377 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  Trying to understand strings and lists of strings Konstantin23 2 757 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  place 2 windows exactly above each other janeik 3 924 Jul-23-2023, 03:12 AM
Last Post: deanhystad
  pickle problem DPaul 13 4,743 Sep-27-2022, 05:25 PM
Last Post: DPaul
  Splitting strings in list of strings jesse68 3 1,757 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  TypeError: cannot pickle n00sferatu 1 2,648 Dec-14-2021, 03:52 PM
Last Post: yakkaligiri
  Multiprocessing Can't pickle local object law 1 15,976 Aug-30-2021, 02:49 PM
Last Post: law
  Cannot 'break' from a "for" loop in a right place tester_V 9 3,983 Feb-17-2021, 01:03 AM
Last Post: tester_V
  Save/Loading using pickle Scordomaniac 4 3,029 Nov-24-2020, 06:11 PM
Last Post: Scordomaniac
  Where should I place GPIO.cleanup() shallanq 2 2,154 Apr-11-2020, 05:02 AM
Last Post: shallanq

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020