From f6237d63d965f95afb78504bf8cb128812cc8d07 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Mon, 2 Feb 2009 11:38:23 -0500 Subject: [PATCH] note about using pickle --- examples/custom_type.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/custom_type.py b/examples/custom_type.py index ca02b1c7a..69cd567c8 100644 --- a/examples/custom_type.py +++ b/examples/custom_type.py @@ -122,6 +122,8 @@ assert db.test.find_one()["custom"].x() == 5 # We can take this one step further by encoding to binary, using a user defined # subtype. This allows us to identify what to decode without resorting to tricks # like the "_type" field used above. +# NOTE: you could just pickle the instance and save that. What we do here is a +# little more lightweight... def to_binary(custom): return Binary(str(custom.x()), 128) def from_binary(binary):