Re: memory allocation for Python list
dmitrey: As I have mentioned, I don't know final length of the list, but usually I know a good approximation, for example 400. There is no reserve()-like method, but this is a fast enough operation you can do at the beginning: l = [None] * 400 It may speed up your code, but the final resizing may kill your performance anyway. You can try it. Just using Psyco is probably better. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: memory allocation for Python list
Just write it in C and compile it into a file.so/pyd =) 2008/3/26, [EMAIL PROTECTED] [EMAIL PROTECTED]: dmitrey: As I have mentioned, I don't know final length of the list, but usually I know a good approximation, for example 400. There is no reserve()-like method, but this is a fast enough operation you can do at the beginning: l = [None] * 400 It may speed up your code, but the final resizing may kill your performance anyway. You can try it. Just using Psyco is probably better. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: memory allocation for Python list
dmitrey: As I have mentioned, I don't know final length of the list, but usually I know a good approximation, for example 400. You may want to use collections.deque too, it doesn't produce a Python list, but it's quite fast in appending (it's a linked list of small arrays). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list