| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/pythran/analyses/__pycache__/ |
Upload File : |
�
cR�a8 � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZmZ dd lmZ dd lmZ dd lZdd lZ G d
� de
� � Zd S )z8 LazynessAnalysis returns number of time a name is use. � )�Aliases)�ArgumentEffects)�Identifiers)�PureExpressions)�FunctionAnalysis)�PythranSyntaxError)�get_variable�isattrNc � � � e Zd ZdZ ed� � Zej Z� fd�Z d� Z
d� Z� fd�Zd� Z
d� Zd � Zd
� Zd� ZeZd� Zd
� Zd� Zd� Zd� Z� fd�Z� xZS )�LazynessAnalysisa�
Returns number of time a name is used.
+inf if it is use in a
loop, if a variable used to compute it is modify before
its last use or if it is use in a function call (as it is not an
interprocedural analysis)
>>> import gast as ast, sys
>>> from pythran import passmanager, backend
>>> code = "def foo(): c = 1; a = c + 2; c = 2; b = c + c + a; return b"
>>> node = ast.parse(code)
>>> pm = passmanager.PassManager("test")
>>> res = pm.gather(LazynessAnalysis, node)
>>> res['a'], res['b'], res['c']
(inf, 1, 2)
>>> code = '''
... def foo():
... k = 2
... for i in [1, 2]:
... builtins.print(k)
... k = i
... builtins.print(k)'''
>>> node = ast.parse(code)
>>> res = pm.gather(LazynessAnalysis, node)
>>> (res['i'], res['k']) == (sys.maxsize, 1)
True
>>> code = '''
... def foo():
... k = 2
... for i in [1, 2]:
... builtins.print(k)
... k = i
... builtins.print(k)'''
>>> node = ast.parse(code)
>>> res = pm.gather(LazynessAnalysis, node)
>>> (res['i'], res['k']) == (sys.maxsize, 2)
True
>>> code = '''
... def foo():
... d = 0
... for i in [0, 1]:
... for j in [0, 1]:
... k = 1
... d += k * 2
... return d'''
>>> node = ast.parse(code)
>>> res = pm.gather(LazynessAnalysis, node)
>>> res['k']
1
>>> code = '''
... def foo():
... k = 2
... for i in [1, 2]:
... builtins.print(k)'''
>>> node = ast.parse(code)
>>> res = pm.gather(LazynessAnalysis, node)
>>> res['k'] == sys.maxsize
True
>>> code = '''
... def foo():
... k = builtins.sum
... builtins.print(k([1, 2]))'''
>>> node = ast.parse(code)
>>> res = pm.gather(LazynessAnalysis, node)
>>> res['k']
1
�infc � �� t � � | _ t � � | _ t � � | _ t � � | _ t � � | _ t � � | _ t � � | _ t t | � � � t t t � � d S �N)�dict�result�
name_count�use�set�dead�pre_loop_count�in_omp�
name_to_nodes�superr �__init__r r r )�self� __class__s ��D/usr/lib/python3/dist-packages/pythran/analyses/lazyness_analysis.pyr zLazynessAnalysis.__init__[ s� �� ��f�f����&�&����6�6��� �E�E�� � #�f�f����e�e���!�V�V���
���%�%�.�.���/>� @� @� @� @� @� c �� �� �fd�| j � � � D � � }| j � |� � |D ]3}d� | j | D � � }| j � |� � �4d S )Nc �"