Tie::Array::CSV is now more efficient on row ops
The major improvement in 0.04 was inspired by a conversation with David Mertens at the WindyCity.pm imformal meeting a couple weeks back. As I was explaining T::A::CSV to the group over a couple beers, David asked if the file is updated at every change. I said proudly that it was, however he noted that this has some drawbacks.
His first point was that it is expensive to write out the whole row even when the next operation might be on the same row. To address this, now, by default, same-row operations do not write out on each change. More specifically as long as the reference to the row stays in scope, the related line is not updated. This allows for more efficient operations like
map on the rows.
Additionally, this feature is optional, controlled by the
hold_row option to the constructors, which is true by default.
His second point, which I cannot do anything about, is related to Tie::File. He asks if changes to the top of the file are more costly than near the bottom? Honestly I didn’t know so I ask you, the reader; if you know please comment. Either way, I don’t see changing away from Tie::File for line access, but it is something worth understanding.
One other change is that the
new constructors now have the same option passing mechanism. In 0.03 the
new constructor allowed a more flexible system for passing options, but the
tie constructor did not. This mechanism has been ported back to the
tie constructor as of the new release.
I hope Tie::Array::CSV can help save people some effort when using CSV files, if you think it might help you, please check it out, and as always, let me know your thoughts.
P.S. development is hosted on my GitHub.