It makes code cleaner and easier to read / work-with when things are nicely divided into functions. Is there any memory usage overhead to passing (large) objects back and forth between different method calls? ie
Model 1 - Unified:
data1 = getData("1")
# Do stuff to data1
# ...
saveData(data1)
data2 = getData("2")
# Do stuff to data2
# ...
saveData(data2)
Model 2 - Divided:
def doStuff(dat):
# Do stuff to data
# ...
return dat
data1 = getData("1")
data1 = doStuff(data1)
saveData(data1)
data2 = getData("2")
data2 = doStuff(data2)
saveData(data2)
当然有,但是除非您做一些疯狂的事情,否则它相对于程序的其余部分来说应该很小,只有几千字节的大小。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.