[Python] importing an array consuming too much RAM memory

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    I have a file lets say abc.py (size 97 MB) containing two arrays named x_train and y_train.

    In another file lets say test.ipynb I used the following command:

    from abc import x_train, y_train

    I create two python environment in anaconda:

    1. Python=3.12.10, numpy=2.1.3
    2. Python=3.10.15, numpy=1.26.4

    For case 1 above, the code keeps consuming ram memory (>10GB) until RAM is full and system hanged.

    For case 2 above, the same code executed within seconds.

    I want to know the reason what went wrong ? I searched on internet didn't find what I am looking for. Can you guys help me in understanding this. How should I load the array more efficiently.

    I have always used from numpy import *, from math import * but never faced this problem

    In case you need other package versions, I can update it here. Thanks.

    Continue reading...

Compartilhe esta Página