public static string dumps(CodeContext/*!*/ context, object obj, [DefaultParameterValue(null)] object protocol, [DefaultParameterValue(null)] object bin) { //??? possible perf enhancement: use a C# TextWriter-backed IFileOutput and // thus avoid Python call overhead. Also do similar thing for LoadFromString. object stringIO = PythonOps.Invoke(context, DynamicHelpers.GetPythonTypeFromType(typeof(PythonStringIO)), SymbolTable.StringToId("StringIO")); PicklerObject pickler = new PicklerObject(context, stringIO, protocol, bin); pickler.dump(context, obj); return Converter.ConvertToString(PythonOps.Invoke(context, stringIO, SymbolTable.StringToId("getvalue"))); }
public static void dump(CodeContext/*!*/ context, object obj, object file, [DefaultParameterValue(null)] object protocol, [DefaultParameterValue(null)] object bin) { PicklerObject pickler = new PicklerObject(context, file, protocol, bin); pickler.dump(context, obj); }