Python 3.x Python3脚本使用了太多内存

Python 3.x Python3脚本使用了太多内存,python-3.x,memory-management,Python 3.x,Memory Management,作为IT课程的家庭作业,我需要编写一个脚本,检查修改后的输入数中的最高功率4,但我只能使用8MB的RAM。我使用这个对数函数,所以我的代码如下所示: 来自数学导入日志,楼层 n=int(输入()) 数字=[] 对于范围(0,n)内的i: number.append(floor(int(input())/10)) 以数字表示的i: 打印(4**层(日志(i,4))) 但是我在我的电脑上检查了这个脚本,它使用了超过8MB的内存 Partition of a set of 74690 objects

作为IT课程的家庭作业,我需要编写一个脚本,检查修改后的输入数中的最高功率4,但我只能使用8MB的RAM。我使用这个对数函数,所以我的代码如下所示:

来自数学导入日志,楼层
n=int(输入())
数字=[]
对于范围(0,n)内的i:
number.append(floor(int(input())/10))
以数字表示的i:
打印(4**层(日志(i,4)))
但是我在我的电脑上检查了这个脚本,它使用了超过8MB的内存

Partition of a set of 74690 objects. Total size = 8423721 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0  23305  31  2100404  25   2100404  25 str
     1  19322  26  1450248  17   3550652  42 tuple
     2   5017   7   724648   9   4275300  51 types.CodeType
     3   9953  13   716915   9   4992215  59 bytes
     4    742   1   632536   8   5624751  67 type
     5   4618   6   628048   7   6252799  74 function
     6    742   1   405720   5   6658519  79 dict of type
     7    187   0   323112   4   6981631  83 dict of module
     8    612   1   278720   3   7260351  86 dict (no owner)
     9     63   0   107296   1   7367647  87 set
<197 more rows. Type e.g. '_.more' to view.>
一组74690个对象的分区。总大小=8423721字节。
索引计数%Size%累计%Kind(类/类的目录)
0 23305 31 2100404 25 2100404 25街
1 19322 26 1450248 17 3550652 42元组
2 5017 7 724648 9 4275300 51类型。代码类型
39953137169159999221559字节
4 742 1 632536 8 5624751 67型
5 4618 6 628048 7 6252799 74功能
6 742 1 405720 5 6658519 79类型的目录
7 187 0 323112 4 6981631 83模块目录
8 612 1 278720 3 7260351 86 dict(无所有者)
96301072961736764787套
但是,在我的手机上,此脚本仅使用2.5MB:

Partition of a set of 35586 objects. Total size = 2435735 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0   9831  28   649462  27    649462  27 str
     1   9014  25   365572  15   1015034  42 tuple
     2   4669  13   261232  11   1276266  52 bytes
     3   2357   7   198684   8   1474950  61 types.CodeType
     4    436   1   166276   7   1641226  67 type
     5   2156   6   155232   6   1796458  74 function
     6    436   1   130836   5   1927294  79 dict of type
     7     93   0    87384   4   2014678  83 dict of module
     8    237   1    62280   3   2076958  85 dict (no owner)     9   1091   3    48004   2   2124962  87 types.WrapperDescriptorType
<115 more rows. Type e.g. '_.more' to view.>
一组35586个对象的分区。总大小=2435735字节。 索引计数%Size%累计%Kind(类/类的目录) 09831286494622764946227街 1 9014 25 365572 15 1015034 42元组 2 4669 13 261232 11 1276266 52字节 3 2357 7 198684 8 1474950 61类型。代码类型 44361166276164122667型 5 2156 6 155232 6 1796458 74功能 643611308365192729479型目录 7 93 0 87384 4 2014678 83模块目录 8237 162280 3 2076958 85 dict(无所有者)9 1091 3 48004 2 2124962 87类型。包装描述符类型 我试着把列表改成元组,但没什么不同


是否有可能减少/限制RAM的使用?

n的值是多少?一个从1到1000的自然数,但在输入之前使用了那么多RAM