python - Web2py - Sharing a list among modules -
i have list of id's, got database insertion, send other functions in other modules. have main module asd.py , want share list id_list functions in other 2 modules : foo.py , bar.py . simply:
in asd.py
def asd(): id_list = list() # insertion append id_list foo.f1(id_list) bar.f1(id_list) my question id_list copied value or reference, assume big list. , approach "performance-wise" ?
thank you.
id_list copied reference, although mutable objects weird edge-case in regard. if foo.f1 call executes id_list = 7, copy of id_list in asd function not change. however, if foo.f1 calls id_list.append(9), 9 appear @ end of id_list in asd function call. there no implicit copying of list.
Comments
Post a Comment