dump data to pickled bytes

dumping a byte string

Dump data to pickled object byte string.

Security awareness, only unpickle data you trust and review considerations for unpickling data. See more information at pickle section

maci.pickledumpbytes -> bytes

Basic Example of dumping data to pickled byte string using default positional parameter

pickled_data = maci.pickledumpbytes(data)

In this example, we simply dump data using the pickledumpbytes function and pass any data as an argument to the function to dump it to pickled object data, and assign the returned data to a variable.

combining pickle with maci to store data to file

To store pickled data to a file, it is more encouraged to store it as a byte string value rather than a whole executable pickle file. The byte string itself is not executable yet as it is stored as a value that can be safely tested (using your own means) before loading it. This approach enables the ability to still store your pickle data to a file as an alternative, and control what byte data is coming in instead of just loading/executing a whole pickle file.

Example storing pickled data to a file as a value using maci, and loading it back

# dumping data
maci_data =
maci_data.pickled_data = maci.pickledumpbytes(my_data)
maci.dump('', maci_data)

# loading data
loaded_data = maci.load('')
my_data = maci.pickleloadbytes(maci_data.pickled_data)

In the example part for dumping, we simply create an empty maci object using and use the pickledumpbytes function on our data to assign it to a new attribute name created on our maci object, then dump the maci data using maci.dump to a file called ''.

In the example part for loading the data back, we simply load in the file called '' using maci.load and assign the newly imported maci object to a variable, then using the partner function maci.pickleloadbytes, we unpickle the attribute name on the maci object with the assigned pickled byte string data back to a variable.

Right before unpickling the data, that could be a point to check the integrity of the byte string value before processing it.

partner functions

Functions that are related for pickledumpbytes

maci.pickleloadbytes -> Load data from pickled bytes

parameters & arguments

Describes all parameter functionality and accepted data types

data: Any

First and only required positional argument. Accepts Any

Use this parameter to pass any data to dump to pickled byte string

This uses the native pickle library shipped with the python standard library for its underlying functionality. For more information on the pickle library and official security concerns with pickling, visit:

Last updated