Do we need to declare global for a variable if we only read it?
<p>consider this  </p>

<pre><code># global variable
i_am_global = {}

def get_global():
    global i_am_global # declare 1
    if i_am_global is not None:
        return i_am_global
    global i_am_global # declare 2
    i_am_global = do_something()
    return i_am_global
def main():
    get_global()
if __name__ == "__main__":
    main()
</code></pre>

<p>in this scenario where do we need to put global ? at # declare 1 or at # declare 2? and why?  </p>

<p>This is because I heard(so I am asking this question) that global causes memory overhead. Please correct my understanding  </p>

<p>Thank you</p>
