Is there a better, more efficient way to get the post id outside the loop?

An alternative to your way would be to access the $post global:

global $post
echo $post->ID;

But

  1. It won’t make a noticeable difference, either way
  2. If you want to increase efficiency, you ought to be looking elsewhere…

EDIT, pertaining to comments:

what about get_the_ID();?

–> Needs to be run inside the Loop.

i have tried both options (get_the_ID and accessing $post global) both give me a wrong id.

If the latter is the case, you, or some plugin you are using, has not properly reset postdata.

You say to look elsewhere… where should I be looking?

I have no idea what it is you are writing. But if you experience resource bottlenecks or inefficiency, retrieval of the current post ID is likely not the cause.