fix crash in staticmethods without explicit positional argument (ticket 804)
store GIL state in temp variable to safely keep it across generator yields (fixes ticket 803)
avoid GIL state temp overhead in sections that do not contain yields