utils.is_instance() particularly type_util.deep_type() is very slow for large collection

Code Reference: https://gitlab.com/datadrivendiscovery/d3m/-/blob/devel/d3m/utils.py#L169-181

The code is directly calling type_util.deep_type. The benchmark for deep_type is as follows:

Reproduce By:

>>> import timeit
>>> from pytypes import type_util
>>> timeit.timeit(lambda: type_util.deep_type({str(i) for i in range(10)}), number=1)
0.00031373500041809166
>>> timeit.timeit(lambda: type_util.deep_type({str(i) for i in range(100)}), number=1)
0.0010653330000423011
>>> timeit.timeit(lambda: type_util.deep_type({str(i) for i in range(100)}), number=1)
0.0008560500000385218
>>> timeit.timeit(lambda: type_util.deep_type({str(i) for i in range(1000)}), number=1)
0.03028174599967315
>>> timeit.timeit(lambda: type_util.deep_type({str(i) for i in range(10000)}), number=1)
2.6877004739999393
>>> timeit.timeit(lambda: type_util.deep_type({str(i) for i in range(100000)}), number=1)
423.23688415299966
>>> 

Note that

>>> timeit.timeit(lambda: {str(i) for i in range(100000)}, number=1)
0.032087536999824806

I am using SKCountVectorizer primitive to build pipeline and when I pickelize the fitted runtime, it is extremely slow (actually it is not slow, it does not even return) and I find out that it hangs at the line https://gitlab.com/datadrivendiscovery/d3m/-/blob/devel/d3m/metadata/params.py#L80. There is a huge collection (around 100K and it is the vocabulary) passed into the function.