Format metrics for the carbon pickle protocol

def _send_picklemetrics(metrics):
    '''
    Format metrics for the carbon pickle protocol
    '''

    metrics = [(metric_name, (timestamp, value))
               for (metric_name, value, timestamp) in metrics]

    data = cPickle.dumps(metrics, -1)
    payload = struct.pack(b'!L', len(data)) + data

    return payload