Format: application/x-python-code
⬇ Download File (1.9 KB)
   1  o
   2  
   3  .'hj�@s�dZddlZddlmZmZdeedeedffdd�Zd	ed
   4  edefdd�Zd
   5  edeeeffdd�Zdedeedfde	fdd�Z
   6  dS)a	
   7  Given a list of integers, made up of (hopefully) a small number of long runs
   8  of consecutive integers, compute a representation of the form
   9  ((start1, end1), (start2, end2) ...). Then answer the question "was x present
  10  in the original list?" in time O(log(# runs)).
  11  �N)�List�Tuple�list_�return.cCs�t|�}g}d}tt|��D]1}|dt|�kr%||||ddkr%q||d|d�}|�t|d|dd��|}qt|�S)aRepresent a list of integers as a sequence of ranges:
  12      ((start_0, end_0), (start_1, end_1), ...), such that the original
  13      integers are exactly those x such that start_i <= x < end_i for some i.
  14  
  15      Ranges are encoded as single integers (start << 32 | end), not as tuples.
  16      ������r)�sorted�range�len�append�
  17  _encode_range�tuple)r�sorted_list�ranges�
  18  last_write�i�
  19  current_range�r�DC:\Users\shubh\Videos\agent\nova\Lib\site-packages\idna/intranges.py�intranges_from_listsr�start�endcCs|d>|BS)N� r)rrrrrr"sr�rcCs|d?|d@fS)Nrl��r)rrrr�
  20  _decode_range&sr�int_rcCsvt|d�}t�||�}|dkr%t||d�\}}||kr$|kr%dS|t|�kr9t||�\}}||kr9dSdS)z=Determine if `int_` falls into one of the ranges in `ranges`.rrTF)r�bisect�bisect_leftrr
  21  )rr�tuple_�pos�left�right�_rrr�intranges_contain*s
  22  �r#)�__doc__r�typingrr�intrrr�boolr#rrrr�<module>s"