Хранение объектов Python в списке Python против массива Numpy фиксированной длины

Выполняя некоторые работы по биоинформатике, я размышлял о последствиях сохранения экземпляров объектов в массиве Numpy, а не в списке Python, но во всех проведенных мною тестах производительность была хуже в каждом случае. Я использую CPython. Кто-нибудь знает причину почему?

В частности:

What are the performance impacts of using a fixed-length array numpy.ndarray(dtype=object) vs. a regular Python list? Initial tests I performed showed that accessing the Numpy array elements was slower than iteration through the Python list, especially when using object methods. Why is it faster to instantiate objects using a list comprehension such as [ X() for i in range(n) ] instead of a numpy.empty(size=n, dtype=object)? What is the memory overhead of each? I was not able to test this. My classes extensively use __slots__, if that has any impact.

Ответы на вопрос(1)

Ваш ответ на вопрос