← Back
Editing: inlining.cpython-311.pyc
� cR�ad � �x � d Z ddlmZmZ ddlmZ ddlZddlZ G d� de� � Z G d� dej � � ZdS ) z! Inlining inline functions body. � )� Inlinable�Aliases)�TransformationNc �V � � e Zd ZdZ� fd�Zd� ZeZeZeZeZ eZ eZeZeZ eZeZd� Z� xZS )�Inlininga Inline one line functions. >>> import gast as ast >>> from pythran import passmanager, backend >>> pm = passmanager.PassManager("test") >>> node = ast.parse(''' ... def foo(a, b): ... return b + b * a ... def bar(b): ... return foo(2 * b, b) * foo(b, b)''') >>> _, node = pm.apply(Inlining, node) >>> print(pm.dump(backend.Python, node)) def foo(a, b): return (b + (b * a)) def bar(b): __pythran_inlinefooa0 = (2 * b) __pythran_inlinefoob0 = b __pythran_inlinefooa1 = b __pythran_inlinefoob1 = b return ((__pythran_inlinefoob0 + (__pythran_inlinefoob0 * __pythran_inlinefooa0)) * (__pythran_inlinefoob1 + (__pythran_inlinefoob1 * __pythran_inlinefooa1))) c � �� d| _ t � � | _ d| _ t t | � � � t t � � dS )z6 fun : Function {name :body} for inlinable functions. Fr N) �update�list�defs� call_count�superr �__init__r r )�self� __class__s ��@/usr/lib/python3/dist-packages/pythran/optimizations/inlining.pyr zInlining.__init__% sB �� �����F�F�� ���� �h����&�&�y�'�:�:�:�:�:� c � � | j p t � � t � � c}| _ | � |� � | j |c}| _ ||gz S )z3 Add new variable definition before the Statement. )r r � generic_visit)r �node� save_defs�new_defss r � visit_StmtzInlining.visit_Stmt, sP � �#�y�2�D�F�F�D�F�F�� �4�9����4� � � �"�i����$�)��4�&� � r c � � | j |j }t |� � dk �r�t t |� � � � }t |t j � � �r�|j | j v �r�d| _ t j | j |j � � }t � � }|j }||j j t |j � � t |j j � � z d� z }t! |j j |� � D ]�\ }}d� |j |j | j � � } t j | t j � � dd�� � } | j � t j | g|d�� � � � t j | t j � � dd�� � ||j <