
On Tue, Dec 28, 2021 at 1:15 AM Christopher Barker <pythonchb@gmail.com> wrote:
On Mon, Dec 27, 2021 at 4:07 PM Steven D'Aprano
Julia (if I recall correctly) has a nice syntax for automatically turning any function or method into an element-wise function:
And numpy has an even easier one: np.log(a_scalar) np.log(an_array)
I have an @elementwise decorator I use for teaching decorators. I could dig it up, but everyone here could write it too. The main work is simply returning the same kind of collection that was passed in (as opposed to, e.g. always a list). But that's 2 lines of work. -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.