i'm pretty much new at python,I know very good C-programming When calling the follwing function in C many time it will cause an memory error:
#include <stdio.h>
#include <stdlib.h>
char *foo(){
char *a=(char*)malloc(1000);
return a;
}
void main(){
char *A;
while(1){
A=foo() // Will cause memory leack Or some kind of error and crash
}
}
since each call for the function will allocate new memory block and when the function end it wont be free ... ending "eating" all the available memory My question: is the following Python function will cause the same when calling many times???:
def foo():
data=[]
for i in range(0,1000):
data.append(str(i))
return data
while(1):
data=foo()
I'm asking cause i know that "data" is a list type Object meaning it's like an array in C ... Thanks a lot!