Skip to main content

pickle / unpickle variables

Project description

pickle / unpickle variables

Tested against Windows 10 / Python 3.10 / Anaconda

pip install varpickler

decode_var(obj: Any, pickle_or_dill: str = 'dill', base: str = 'base64', str_decode: str | None = None) -> Any
    Decode a Python object that was encoded using either the 'pickle' or 'dill' library,
    and then decode the baseXX encoded result.
    
    Parameters:
        obj (str or bytes): The encoded object to be decoded.
        pickle_or_dill (str, optional): The library to be used for decoding.
            Valid options are 'pickle' or 'dill'. Defaults to 'dill'.
        base (str, optional): The base encoding used in the encoded object.
            Defaults to 'base64'.
        str_decode (str, optional): The string encoding used after baseXX encoding.
            If None, no additional string decoding is performed. Defaults to None.
    
    Returns:
        object: The decoded object.
    
    Example:
        import numpy as np
        obj = np.array([23, 34, 4])
        a1 = encode_var(obj, pickle_or_dill="dill", base="base64", str_encode=None)
        a2 = encode_var(obj, pickle_or_dill="dill", base="base64", str_encode="utf-8")
        a3 = decode_var(a1, pickle_or_dill="dill", base="base64", str_decode=None)
        print(a3)
        a4 = decode_var(a2, pickle_or_dill="dill", base="base64", str_decode="utf-8")
        print(a4)
    
        [23 34  4]
        [23 34  4]
encode_var(obj: Any, pickle_or_dill: str = 'dill', base: str = 'base64', str_encode: str | None = None) -> str | bytes
        Encode a Python object using either the 'pickle' or 'dill' library, and then encode the result using baseXX encoding.
    
        Parameters:
            obj (object): The object to be encoded.
            pickle_or_dill (str, optional): The library to be used for encoding.
                Valid options are 'pickle' or 'dill'. Defaults to 'dill'.
            base (str, optional): The base encoding to be used.
                Defaults to 'base64'.
            str_encode (str, optional): The string encoding to be used after baseXX encoding.
                If None, no additional string encoding is performed. Defaults to None.
    
        Returns:
            str or bytes: The encoded object. If 'str_encode' is None, a bytes object is returned.
                Otherwise, a string object is returned.
    
        Example:
            obj = np.array([23, 34, 4])
            >>> a1 = encode_var(obj, pickle_or_dill="dill", base="base64", str_encode=None)
            >>> print(a1)
            b'gAWVtgAAAAAAAACMCmRpbGwuX2RpbGyUjA1fY3JlYXRlX2FycmF5lJOUKIwVbnVtcHkuY29yZS5t
    dWx0aWFycmF5lIwMX3JlY29uc3RydWN0lJOUjAVudW1weZSMB25kYXJyYXmUk5RLAIWUQwFilIeU
    KEsBSwOFlGgGjAVkdHlwZZSTlIwCaTSUiYiHlFKUKEsDjAE8lE5OTkr/////Sv////9LAHSUYolD
    DBcAAAAiAAAABAAAAJR0lE50lFKULg==
    '
    
            >>> a2 = encode_var(obj, pickle_or_dill="dill", base="base64", str_encode="utf-8")
            >>> print(a2)
            'gAWVtgAAAAAAAACMCmRpbGwuX2RpbGyUjA1fY3JlYXRlX2FycmF5lJOUKIwVbnVtcHkuY29yZS5t
            dWx0aWFycmF5lIwMX3JlY29uc3RydWN0lJOUjAVudW1weZSMB25kYXJyYXmUk5RLAIWUQwFilIeU
            KEsBSwOFlGgGjAVkdHlwZZSTlIwCaTSUiYiHlFKUKEsDjAE8lE5OTkr/////Sv////9LAHSUYolD
            DBcAAAAiAAAABAAAAJR0lE50lFKULg=='

	

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

varpickler-0.10.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

varpickler-0.10-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file varpickler-0.10.tar.gz.

File metadata

  • Download URL: varpickler-0.10.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for varpickler-0.10.tar.gz
Algorithm Hash digest
SHA256 a47d0aa1cdeecbee5f4241e46117e20317bd9852536acdc6c4f2c8546ffaa51c
MD5 fad3d3571985813edc5ab95e11d944dc
BLAKE2b-256 7c03f7acc4cdd406f27275a37700eae2d5bccd6630e2cde7de158f045482cf66

See more details on using hashes here.

File details

Details for the file varpickler-0.10-py3-none-any.whl.

File metadata

  • Download URL: varpickler-0.10-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for varpickler-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a886bc308179cc1247f9c66e86bcc135fde539b57d302ea56f63e1326e736506
MD5 73f1c28641a5b85a9ad8c89f82a197aa
BLAKE2b-256 6058f4211776b1bf47c90ea8c10f838fee5dbd2eb85130bf2adcf526a790d777

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page