All contributions

dgilland/pydash

pydash

A Python utility library modelled on Lo-Dash from JavaScript. It offers ready-made operations on lists, dicts and strings in a functional style.

Language
Python
GitHub stars
1,449
Merged changes
1
Project site
pydash.readthedocs.io

What we changed

fill no longer grows the list or duplicates elements when start comes after end, and negative indices work as they do in Python slices.

What this work shows

  • Python list slicing and negative indices
  • In-place list mutation
  • Parametrised tests with pytest
What was broken

fill grew the list instead of doing nothing

When start was greater than end, fill glued overlapping slices of the list together: fill([1, 2, 3, 4], "x", 4, 1) gave [1, 2, 3, 4, 3, 2, 3]. Elements were duplicated and no value was written at all.

How we fixed it

An empty range leaves the list alone

start and end are clamped to the range from 0 to the list length, with negative indices handled as in slices, and values are written in place in a loop. When start is not less than end the list stays the same, as with lodash's _.fill.

#257

Merged change 1

  1. #257 Fix `fill` growing the array when `start` comes after `end` Merged 20 September 2026

What it taught us

We test functions against the order and sign of their arguments: here a reversed range glued overlapping slices together and grew the list. The fix keeps the in-place mutation and parity with lodash's _.fill.

More about this technology: Python

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.