Message305171
Thinking back to my signal processing days, I have to agree that our weightings (filter definitions) were usually separate from our data (live signals). Similarly, systems engineering trade studies all maintained feature weights separately from the assessments of the individual options.
The comment from my original RFE about avoiding expanding value -> weight/frequency mappings "to a full iterable all the time" doesn't actually make much sense in 3.x, since m.keys() and m.values() are now typically able to avoid data copying.
So +1 from me for the separates "weights" parameter, with the m.keys()/m.values() idiom used to handle mappings like Counter.
As another point in favour of that approach, it's trivial to build zero-copy weighted variants on top of it for mappings with cheap key and value views:
def weighted_mean(mapping):
return statistics.mean(mapping.keys(), mapping.values())
By contrast, if the lowest level primitive provided is a mapping based API, then when you do have separate values-and-weights iterables, you're going to have a much harder time avoiding building a completely new container. |
|
Date |
User |
Action |
Args |
2017-10-29 02:23:26 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger, gregory.p.smith, steven.daprano, oscarbenjamin, wolma |
2017-10-29 02:23:26 | ncoghlan | set | messageid: <1509243806.14.0.213398074469.issue20479@psf.upfronthosting.co.za> |
2017-10-29 02:23:26 | ncoghlan | link | issue20479 messages |
2017-10-29 02:23:24 | ncoghlan | create | |
|