You can use a show path construction decoration that you apply using a postaction to place the coordinates. That way, the underlying path is not changed at all.
Here's a style put coordinates that takes an optional argument to name the coordinates (default is coordinate):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\newcounter{coordinateindex}
\begin{document}
\tikzset{
put coordinates/.style={
initialize counter/.code={
\setcounter{coordinateindex}{0}
},
initialize counter,
decoration={
show path construction,
moveto code={
\stepcounter{coordinateindex}
\coordinate (#1\thecoordinateindex) at (\tikzinputsegmentfirst);
},
lineto code={
\stepcounter{coordinateindex}
\coordinate (#1\thecoordinateindex) at (\tikzinputsegmentlast);
},
curveto code={
\stepcounter{coordinateindex}
\coordinate (#1\thecoordinateindex) at (\tikzinputsegmentlast);
},
closepath code={
\stepcounter{coordinateindex}
\coordinate (#1\thecoordinateindex) at (\tikzinputsegmentlast);
},
},
postaction={decorate}
},
put coordinates/.default=coordinate
}
\begin{tikzpicture}
\draw [put coordinates] (0,0) -- (3,2) to [out=90, in=0] (4,7)-- (-2,1);
\foreach \i in {1,...,\thecoordinateindex}{
\fill (coordinate\i) circle [radius=2pt] node [above left] {\i};
}
\draw [red, put coordinates=secondpath] (0,1) -- (5,4) -- (4,1);
\foreach \i in {1,...,\thecoordinateindex}{
\fill (secondpath\i) circle [radius=2pt] node [above left] {\i};
}
\end{tikzpicture}
\end{document}