Possible Fix to deal with Python Memory usage

前端 未结 5 2091
一个人的身影
一个人的身影 2021-01-16 14:11

I have the following class:

 class C1:
    STORE = []
    TYPE = []
    ITEMS = []
    PRICE = []


    def __init__(self,STORE,TYPE,ITEMS,PRICE):
        se         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-16 14:53

    Items are alphanumerically ordered [...]

    With all this data in a class, I run 'reports' with some 'complex' computation involved.

    Are there data structures other than lists which would consume less memory and improve my performance?

    I'm just guessing at your algorithms here: linear-time searching? If so, using an OrderedDict may improve performance greatly.

    That won't solve the memory issue, though; consider using a proper database package instead, e.g. SQLite + SQLAlchemy or plain old bsddb with B-trees.

提交回复
热议问题