This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients joern, rhettinger, serhiy.storchaka
Date 2015-05-23.18:44:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1432406675.55.0.272780321774.issue23509@psf.upfronthosting.co.za>
In-reply-to
Content
The OrderedCounter recipe doesn't support well multiset operations, because the result type is hardcoded to Counter. The order is already scrambled. update() and substract() don't work well with overloaded __missing__().

Proposed implementations of __add__ and __or__ simplify the code. If you don't want that overloaded inplace operation affect non-inplace operations (I consider this rather as a benefit), Counter.__iadd__(result, other) can be used instead of result += other.

Optimized __neg__ just contains inlined substraction (note that current implementation of __neg__ and __pos__ violate the open-closed-principle), with removed no-op code.

My second step would be to add C implementation of _keep_positive(), because this function is used in a number of multiset methods. It could be more efficient and preserve the order.

In any case thank you for spending your time Raymond.
History
Date User Action Args
2015-05-23 18:44:35serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, joern
2015-05-23 18:44:35serhiy.storchakasetmessageid: <1432406675.55.0.272780321774.issue23509@psf.upfronthosting.co.za>
2015-05-23 18:44:35serhiy.storchakalinkissue23509 messages
2015-05-23 18:44:35serhiy.storchakacreate