Remove as many new keywords as possible to prevent memory leaks.
In some cases, change API to take in objects instead of pointers (either to require more caution from user about memory management or to make it possible/easier to avoid a new keyword).
In most of these cases, the objects being passed are small/temporary, so I don't think there was too much benefit from passing them as pointers rather than objects in the previous approach.
The most salient case is the DataFrame.col method:
Before the rewrite, it was creating a new copy of the column on the memory heap every time we used it to access a column of values (even if we were just using it for read-only purposes).
It now creates a column in the stack and returns it as an object. If the calling function simply reads values from it and doesn't store it, the column object gets wiped from the stack after use (which is desirable in this case, from a memory management perspective); if it does need to be conserved, the user has to make that happen explicitly (which helps prevent us from accidentally saving copies indefinitely and wasting memory).
new
keywords as possible to prevent memory leaks.new
keyword).In most of these cases, the objects being passed are small/temporary, so I don't think there was too much benefit from passing them as pointers rather than objects in the previous approach.
The most salient case is the
DataFrame.col
method: