[issue39437] collections.Counter support multiplication

2020-01-23 Thread Ammar Askar


Ammar Askar  added the comment:

Duplicate of https://bugs.python.org/issue25478

See Raymond's open PR here: https://github.com/python/cpython/pull/6574

--
nosy: +ammar2
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Consider adding a normalize() method to collections.Counter()

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39437] collections.Counter support multiplication

2020-01-23 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39437] collections.Counter support multiplication

2020-01-23 Thread Dominick Johnson


New submission from Dominick Johnson :

I would love to see collections.Counter support scalar multiplication.

## My Use Case:

I am writing a python script to manage hardware selections for custom-build 
computers. Users are able to select various options from a web interface, and 
the script compiles a list of parts that need purchased.

Each option for user selection has a corresponding Counter object to keep track 
of what parts are needed for that selection. For example, the user option "i5 
Processor" would have a corresponding counter that might looks roughly like 
this: {"i5-": 1, "x Motherboard"}. A user option for "2 TB RAID 10" 
might have {"1 TB HDD": 4}.

The script adds all the counters for the selected options together to produce a 
counter detailing the full parts list for the build.

I'd like to add a feature to the script that allows the user to also specify a 
quantity for certain selections. (Maybe the user wants 2 1TB Storage Drives 
without any kind of RAID setup). It would be really convenient to be able to 
simply multiply the selection's counter by it's quantity before adding it to 
the main counter. e.g. `main_counter += secondary_counter * selection_quantity`

This seems like an extremely simple feature to add, and I would of course be 
willing to add it myself as long as the Python team is willing to accept a pull 
request from me adding this feature. However, I've never contributed to such a 
large project before, so I'm not sure what kind of procedures are in place to 
make it happen.

--
components: Library (Lib)
messages: 360573
nosy: Dominick Johnson
priority: normal
severity: normal
status: open
title: collections.Counter support multiplication
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com