11 Dec 2011 17:51
Re: [Cython] [cython-users] malloc vs PyMem_malloc
mark florisson, 11.12.2011 01:02: > On 10 December 2011 22:00, Stefan Behnel wrote: >> mark florisson, 10.12.2011 21:44: >>> On 10 December 2011 20:39, mark florisson wrote: >>>> On 10 December 2011 19:16, Robert Bradshaw wrote: >>>>> On this note, a useful pattern is >>>>> >>>>> try: >>>>> x = malloc(...) >>>>> finally: >>>>> free(x) >>>>> >>>>> It could be nice to encapsulate this in a context manager. >> >> Absolutely. >> >>>> I think I'd prefer variable-sized arrays that would always get >>>> deallocated on exit of the function >> >> Why? A context manager is much clearer > > That is highly subjective, I think it would be harder to read and > introduce more code blocks and nesting. > >> and gives users total control over >> the lifetime of the memory. > > Yes, but very often you don't need it. And if Cython would support > declarations in blocks you'd get it for free. Supporting that > (disregarding the difficulties of that) would also be helpful in(Continue reading)
RSS Feed