o
    8Î®c5  ã                   @   s(   d dl Z d dlmZ G dd„ deƒZdS )é    N)Útypesc                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚDataModelManagerzBManages mapping of FE types to their corresponding data model
    c                 C   s   i | _ t ¡ | _d S )N)Ú	_handlersÚweakrefÚWeakKeyDictionaryÚ_cache)Úself© r	   úC/tmp/pip-target-vg8gfxp4/lib/python/numba/core/datamodel/manager.pyÚ__init__
   s   zDataModelManager.__init__c                 C   s   t |tjƒsJ ‚|| j|< dS )zNRegister the datamodel factory corresponding to a frontend-type class
        N)Ú
issubclassr   ÚTyper   )r   Ú	fetypeclsÚhandlerr	   r	   r
   Úregister   s   zDataModelManager.registerc                 C   sF   z| j | W S  ty   Y nw | jt|ƒ }|| |ƒ }| j |< |S )zMReturns the corresponding datamodel given the frontend-type instance
        )r   ÚKeyErrorr   Útype)r   Úfetyper   Úmodelr	   r	   r
   Úlookup   s   ÿzDataModelManager.lookupc                 C   s
   |   |¡S )zShorthand for lookup()
        )r   )r   r   r	   r	   r
   Ú__getitem__!   s   
zDataModelManager.__getitem__c                 C   s   t ƒ }| j ¡ |_|S )z’
        Make a copy of the manager.
        Use this to inherit from the default data model and specialize it
        for custom target.
        )r   r   Úcopy)r   Údmmr	   r	   r
   r   &   s   zDataModelManager.copyN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r	   r	   r	   r
   r      s    r   )r   Ú
numba.corer   Úobjectr   r	   r	   r	   r
   Ú<module>   s    