#NEWLINE# def getTupleCreationCode( to_name , elements , emit , context ) : #NEWLINE# #INDENT# if _areConstants ( elements ) : #NEWLINE# #INDENT# getConstantAccess ( to_name = to_name , constant = tuple ( ( element . getConstant ( ) for element in elements ) ) , emit = emit , context = context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# emit ( ( '%s = PyTuple_New( %d );' % ( to_name , len ( elements ) ) ) ) #NEWLINE# context . addCleanupTempName ( to_name ) #NEWLINE# element_name = context . allocateTempName ( 'tuple_element' ) #NEWLINE# for ( count , element ) in enumerate ( elements ) : #NEWLINE# #INDENT# generateExpressionCode ( to_name = element_name , expression = element , emit = emit , context = context ) #NEWLINE# if ( not context . needsCleanup ( element_name ) ) : #NEWLINE# #INDENT# emit ( ( 'Py_INCREF( %s );' % element_name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# context . removeCleanupTempName ( element_name ) #NEWLINE# #UNINDENT# emit ( ( 'PyTuple_SET_ITEM( %s, %d, %s );' % ( element_name , count , element_name ) ) )