def cpickle_dumps(obj):
 if isinstance(obj, dict):
  return cPickle.dumps(obj, 1)
 return cPickle.dumps(obj, cPickle.HIGHEST_PROTOCOL)

def cpickle_dumps ( obj ) : if isinstance ( obj , dict ) : return cPickle . dumps ( obj , 1 ) return cPickle . dumps ( obj , cPickle . HIGHEST_PROTOCOL )
pickle doesnt handle dict sub-classes when using highest_protocol .