def _data():
    """(Lazy)load index data structure for currences

    Load the `data.json` file (created with `gen_data.py`) and index by alpha3,
    code_num, symbol and country.

    Returns:
        Dict[str, Dict[str, Any]]: Currency data indexed by different angles
    """
    global _DATA
    if _DATA is None:
        _DATA = {}
        with open(resource_filename(__name__, 'data.json'), 'r', encoding='utf-8') as f:
            _DATA['alpha3'] = {k: Currency(**v) for k, v in json.load(f).items()}

        _DATA['code_num'] = {d.code_num: d for d in _DATA['alpha3'].values() if d.code_num is not None}
        _DATA['symbol'] = defaultdict(list)
        for d in _DATA['alpha3'].values():
            for s in d.symbols:
                _DATA['symbol'][s] += [d]

        for s, d in _DATA['symbol'].items():
            _DATA['symbol'][s] = sorted(d, key=lambda d: 10000 if d.code_num is None else d.code_num)

        _DATA['name'] = {}
        for d in _DATA['alpha3'].values():
            if d.name in _DATA['name']:
                assert 'Duplicate name "{}"!'.format(d.name)
            _DATA['name'][d.name] = d

        _DATA['country'] = defaultdict(list)
        for d in _DATA['alpha3'].values():
            for cc in d.countries:
                _DATA['country'][cc] += [d]

        for s, d in _DATA['country'].items():
            _DATA['country'][s] = sorted(d, key=lambda d: (
                int(d.symbols == []),  # at least one symbol
                10000 if d.code_num is None else d.code_num,  # official first
                len(d.countries),  # the fewer countries the more specific
            ))

    return _DATA
(Lazy)load index data structure for currences

    Load the `data.json` file (created with `gen_data.py`) and index by alpha3,
    code_num, symbol and country.

    Returns:
        Dict[str, Dict[str, Any]]: Currency data indexed by different angles