Re: PL/Python initialization cleanup - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: PL/Python initialization cleanup
Date
Msg-id 4e1de244-b25a-4eae-9ee3-4993939cb4e7@eisentraut.org
Whole thread Raw
In response to Re: PL/Python initialization cleanup  (Kirill Reshke <reshkekirill@gmail.com>)
List pgsql-hackers
On 14.01.26 22:03, Kirill Reshke wrote:
> For 0004, do we need main_dict at all? it is only used inside _PG_init
> and then its value assigned to PLy_interp_globals...

This was merely a stylistic, defensive choice.  I prefer to keep 
main_dict in a local variable while it is being assembled, and only put 
it into a global variable once it's done.  This reduces the chance of 
accidentally having a partially constructed object globally visible. 
Another point is that main_dict is a borrowed reference, but when we put 
it into the global variable we need to add another reference.  Having 
two separate variables makes this step more explicit.




pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: Refactor replication origin state reset helpers
Next
From: Álvaro Herrera
Date:
Subject: Re: Add missing JIT inline pass for llvm>=17