Yury V. Zaytsev, 07.03.2013 12:16: > Is there any syntax that I can use to do something like this in Cython: > > py_object_ = PyList_New(123); ?
Note that Python has an algorithm for shrinking a list on appending, so this might not be sufficient for your use case. > If not, do you think that this can be added in one way or another? > > Unfortunately, I can't think of a non-disruptive way of doing it. For > instance, if this > > [None] * N > > is given a completely new meaning, like make an empty list (of NULLs), > instead of making a real list of Nones, it will certainly break Python > code. Besides, it would probably be still faster than no pre-allocation, > but slower than an empty list with pre-allocation... > > Maybe > > [NULL] * N ? What do you need it for? Won't list comprehensions work for you? They could potentially be adapted to presize the list. And why won't [None]*N help you out? It should be pretty cheap. Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel