## serialize()


Serialize a Python object to bytes.


Usage


``` python
serialize(obj)
```


Converts the given object into a byte string representation using pickle serialization.


## Parameters


`obj: object`  
The Python object to serialize. Must be picklable.


## Returns


`bytes`  
The serialized byte string.


## Raises


`TypeError`  
If the object cannot be pickled.


## See Also

[deserialize()](deserialize.md#gdtest_docstring_seealso.deserialize)  
Convert bytes back into a Python object.

[to_json()](to_json.md#gdtest_docstring_seealso.to_json)  
Serialize an object to a JSON string instead.


## Examples

``` python
>>> data = serialize({"key": "value"})
>>> isinstance(data, bytes)
```

True
