Does project(function, subspace) extract the values of the function on the subspace?

This is a very basic question. I am new to FEniCS. So my apologies if this has an obvious answer.

Suppose \Omega_{2} is a subspace of \Omega_{1}. Now we define a function space on \Omega_{1} as
FS_omega1 = FunctionSpace(omega1, 'P', 1)
We then solve for a function P(x,y) on \Omega_{1}, where P=Function(FS_omega1)

Now I want to extract the values of P(x,y) on \Omega_{2}.

Will Q = project(P, omega2) give us P(x,y)|_{\Omega_{2}} ?

Please make a minimal example, as it is unclear if:

  1. what version of DOLFINx you are targeting
  2. how you are defining the subspace omega2