New submission from Stefan Behnel:

The C accelerator for the collections.Counter class (_count_elements() in 
_collections.c) is slower than the pure Python versions for data that has many 
unique entries. This is because the fast path for dicts is not taken (Counter 
is a subtype of dict) and the slower fallback path raises exceptions for each 
value that wasn't previously seen. This can apparently make it slower than 
calling get() on Python side.

My suggestion is to drop the fallback path from the accelerator completely and 
to only call the C function when it's safe to use it, e.g. when "type(self) is 
Counter" and not a subclass.

----------
components: Library (Lib)
messages: 193914
nosy: scoder, serhiy.storchaka
priority: normal
severity: normal
status: open
title: C accelerator for collections.Counter is slow
type: performance
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18594>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to