Pass php variable between code elements in same page (Performance problem)

Dear Team,

I setted up a Woocommerce product category template and a product single template with own PHP codes. I call
global $product;
in every code element as I can not call it only once because of every code element needs to be signed. If I understand correctly the signed code elements are separated from each other in same page or template.

How could I give datas through signed code elements in one page? For example:
1st code element:
global $product;
$prod_price = $product->get_price();

2nd code element:
echo $prod_price;

Thank you for checking this question.
Best regards, Andrew

Somehow my website slowed down extremely after update v1.11.1 and WP 6.7.
Now the speed is good, as we changed server to VPS and I took out some queries and updated to v1.11.1.1 but the processor is jumping up to 200% immediately when I get something outside of cache. I would optimize my code. Thank you.

Global variable slowed down the processes but the call of the variables is slowing down the process also. I need to call variables 4 times / product. It would be much better to call them locally, or globally once. I think I could gain 0.5 - 1 seconds / page load. It is huge. I hope you could help in this thing.