Template functions the gil way