Create a ray from camera to a Vector3 point

I have to create a ray from the main camera through an x,y,z point in space I call guidePos. The language uses screen space but no mouse click is used here. I used -

ray = Camera.main.ScreenPointToRay (Camera.main.WorldToScreenPoint(guidePos));

This works exactly how I want it but is probably very slow due to 2 camera calculations. What is the best way to create this ray? Thank you.

You can do somewhere north of a million ScreenPointToRay+WorldToScreenPoint calculations per second on a half-decent modern desktop CPU. If that's your definition of "very slow", then yes, it is. But the thing that would help you the most is to cache Camera.main in a variable so you aren't retrieving it all the time.

private var cam : Camera;

function Awake () {
    cam = Camera.main;
}

What you have there is probably not in fact 'very slow'. However, if you're just asking how to create a ray given two points 'p1' and 'p2', you can do it like this (untested pseudocode):

rayOrigin = p1;
rayDirection = Normalize(p2 - p1);

The normalization step is optional, strictly speaking (although it's often convenient to have the direction vector be unit length). Also, note that the above may fail if p1 and p2 are coincident or nearly coincident.