TIM*_*MEX 2 c++ python garbage-collection
我听说Python有自动"垃圾收集",但C++没有.那是什么意思?
这意味着python用户不需要清理他动态创建的对象,就像你有义务在C/C++中那样做.
C++中的示例:
char *ch = new char[100];
ch[0]='a';
ch[1]='b';
//....
// somewhere else in your program you need to release the alocated memory.
delete [] ch;
// use *delete ch;* if you've initialized *ch with new char;
Run Code Online (Sandbox Code Playgroud)
在python中:
def fun():
a=[1, 2] #dynamic allocation
a.append(3)
return a[0]
Run Code Online (Sandbox Code Playgroud)
python单独关注"a"对象.
归档时间: |
|
查看次数: |
1371 次 |
最近记录: |