• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eriknw / toolz / 87 / 4
100%
master: 100%

Build:
Build:
LAST BUILD BRANCH: python3.6
DEFAULT BRANCH: master
Ran 10 May 2014 01:33PM UTC
Files 11
Run time 2s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

10 May 2014 01:17PM UTC coverage: 100.0%. First build
PEP8_IGNORE=""

push

travis-ci

eriknw
Faster groupby!

Issue #178 impressed upon me just how costly attribute resolution can
be.  In this case, `groupby` was made faster by avoiding resolving the
attribute `list.append`.

This implementation is also more memory efficient than the current
version that uses a `defaultdict` that gets cast to a `dict`.  While
casting a defaultdict `d` to a dict as `dict(d)` is fast, it is still
a fast *copy*.

Honorable mention goes to the following implementation:
```python
def groupby_alt(func, seq):
    d = collections.defaultdict(lambda: [].append)
    for item in seq:
        d[func(item)](item)
    rv = {}
    for k, v in iteritems(d):
        rv[k] = v.__self__
    return rv
```
This alternative implementation can at times be *very* impressive.  You
should play with it!

460 of 460 relevant lines covered (100.0%)

1.0 hits per line

Source Files on job 87.4 (PEP8_IGNORE="")
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 87
  • Travis Job 87.4
  • 623c4482 on github
  • Next Job for PEP8_IGNORE="" on faster_groupby (#88.2)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc