← Back
Editing: list_to_tuple.cpython-311.pyc
� cR�a` � � � d Z ddlmZmZ ddlmZ ddlmZ ddlm Z ddl Zed d ed d ed d ed d ed d ed d fZd� Z d� Z G d� de� � ZdS )zH ListToTuple transforms some List node into more Efficient Tuple nodes. � )�Aliases� FixedSizeList)�MODULES)�Transformation)�path_to_attrN�numpy�full�ones�zeros�empty�concatenate�builtins�tuplec �6 � t | t j � � S �N)� isinstance�ast�List��nodes �E/usr/lib/python3/dist-packages/pythran/optimizations/list_to_tuple.py�islistr s � ��d�C�H�%�%�%� c �@ � t j | j | j � � S r )r �Tuple�elts�ctxr s r �totupler s � ��9�T�Y���)�)�)r c �@ � � e Zd ZdZ� fd�Zd� Zd� Zd� Zd� Zd� Z � xZ S )�ListToTuplea� Replace list nodes by tuple nodes when possible >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(n): import numpy; return numpy.ones([n,n])") >>> pm = passmanager.PassManager("test") >>> _, node = pm.apply(ListToTuple, node) >>> print(pm.dump(backend.Python, node)) def foo(n): import numpy return numpy.ones((n, n)) c �| �� d| _ t t | � � � t t � � d S )NF)�update�superr �__init__r r )�self� __class__s �r r$ zListToTuple.__init__* s0 �� ���� �k�4� � �)�)�'�=�A�A�A�A�Ar c � � t |j � � s| � |� � S t |j � � |_ d| _ | � |� � S )NT)r �value� generic_visitr r"