Access to object location from previous frame in cycles Is there a way to access an objects location data from the previous frame in cycles? I want to make a shader that colors the object accordingly to the distance the object traveled between the current frame and the last one. 
My goal is an animation with moving cubes colored by the "speed" they have.

Also, I guess thats information that is not available in osl?
See the docs about drivers, they're comprehensive.
Also see TextEditor -> Templates -> Python -> Driver Functions

Add a Driver

If your object is key-framed, you can evaluate the F-Curve using a frame number like fcurve[index].evaluate(frame-1) 


Add a Driver to a custom property of your object.

Make a python expression text block with something like the code below, and Run the code so the expression is added to the driver_namespace 

import bpy
from mathutils import Vector

def driver_delta_to_RED(frame):
    # triggered by a frame change, any code inside here gets run.

    p = bpy.data.objects['Plane']
    current_xyz = p.location
    fcurve = p.animation_data.action.fcurves

    x = fcurve[0].evaluate(frame-1)
    y = fcurve[1].evaluate(frame-1)
    z = fcurve[2].evaluate(frame-1)

    # may want to find the top speed first, and normalize
    # this value using that information
    delta = (current_xyz - Vector((x, y, z))).length

    nodes = bpy.data.materials[0].node_tree.nodes
    nodes[1].inputs[0].default_value = (delta, 0, 0, 1.0)

    # the return value is of no relevance and can be static.
    return 0.0

bpy.app.driver_namespace['driver_delta_to_RED'] = driver_delta_to_RED

Add the function call to the Driver 



if it's a frame behind or ahead of what you want, then instead of the Driver, it might make sense to add an application_handler specifically the frame_change_pre or frame_change_post handlers. 

The code for Drivers and frame_change handlers is slightly different, but the app handler docs will describe how to get the current frame from inside the handler function.