Welcome! This repository provides a comprehensive guide and practical examples for understanding and using serializable dictionaries in Python. Dictionaries are fundamental, and knowing how to effectively serialize (save/transmit) and deserialize (load/receive) them is a key skill for any Python developer.
This guide covers everything from basic concepts to advanced techniques, performance considerations, security implications, and real-world applications.
- Clear Explanations: Understand what serialization is and why it's essential.
- Multiple Formats: Explore and compare popular formats:
- JSON: The web standard – lightweight and human-readable.
- Pickle: Python's native format – powerful but with security caveats.
- YAML: Highly readable, great for configuration.
- MessagePack: Fast and compact binary format.
- HDF5: High-performance format for large numerical datasets (often used with NumPy arrays within dictionaries).
- Advanced Techniques: Learn how to handle custom objects, circular references, optimize performance, and manage large data streams.
- Practical Examples: See serialization in action for:
- Configuration Management (
yaml) - API Data Exchange (
json,requests) - Caching (
pickle) - Data Persistence (Simple Inventory System using
json)
- Configuration Management (
- Security Focus: Understand the critical security risks of deserialization (especially
pickle) and the importance of input validation (jsonschema). - Best Practices: Actionable advice on choosing formats, versioning data, handling errors, and testing your code.
- Jupyter Notebooks: Interactive learning experience through three detailed notebooks:
1_Introduction_to_Serialization.ipynb: Basics and common formats.2_Advanced_Serialization_Performance.ipynb: Custom objects, performance, HDF5 comparison.3_Practical_Applications_Best_Practices.ipynb: Real-world use, security, best practices.
- The
jsonconsPackage: PyPi Package JSON Console utility | Simple CLI for JSON handling (see details below).
- Clone the repository:
git clone https://github.com/fapulito/jsoncons-nb.git cd jsoncons-nb - Set up a virtual environment (Recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install dependencies:
- For core notebooks (JSON, Pickle): No external dependencies needed beyond Python 3.
- For advanced examples:
(You'll need to create a
pip install -r requirements.txt
requirements.txtfile listingpyyaml,msgpack-python,requests,jsonschema,h5py,numpy)
- Launch Jupyter:
jupyter notebook # or jupyter lab - Open and run the notebooks (
.ipynbfiles) in order. Happy Serializing! 🎉
