You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PEP does not propose any changes to map, since the use of map with multiple iterable arguments is quite rare. However, this PEP’s ruling shall serve as precedent such a future discussion (should it occur).
If rejected, the feature is realistically not worth pursuing. If accepted, such a change to map should not require its own PEP (though, like all enhancements, its usefulness should be carefully considered). For consistency, it should follow same API and semantics debated here for zip.
I'm +1 on the change, personally. Unassigning myself though since I don't have bandwidth to work on it right now (it seems like a good issue for someone newer looking to contribute some C code).
Hey, I'm the guy who originally suggested strict for zip. I was just using map and wanting the same feature there, which prompted me to find this issue. I too am +1 on implementing it. If you do implement it, I'll be happy to write the documentation.
This closes doors to another extension - adding keyword arguments to map.
Maybe it would be worth considering both at the same time and finding out what would be "joint optimum" to have performant & convenient solutions to both?:
a) map(func, arg1, arg2, c=arg3).
b) map(func, arg1, arg2, strict=True).
What about achieving map(func, arg1, arg2, c=arg3, strict=True)?
Of course, one can always convert func into positional only version for this, but I expect performance penalty for doing so is going to be much larger than performance benefit of map(..., strict) vs startmap(..., zip(..., strict))
Or is there a reason why adding keywords is out of the question?
Activity
brandtbucher commentedon May 30, 2024
PEP 618 says:
I'm +1 on the change, personally. Unassigning myself though since I don't have bandwidth to work on it right now (it seems like a good issue for someone newer looking to contribute some C code).
SweetyAngel commentedon May 30, 2024
I want to implement it, but I cant find the definition of
mapobject. Can you tell me please where it is located?zware commentedon May 30, 2024
See
cpython/Python/bltinmodule.c
Lines 1300 to 1527 in bf098d4
brandtbucher commentedon May 30, 2024
The implementation should be almost identical to the implementation for
zip, which is nice:https://github.com/python/cpython/pull/20921/files#diff-e4fd8b8ee6a147f86c0719ff122aca6dfca36edbd4812c87892698b3b72e40a1
nineteendo commentedon Jun 13, 2024
Brandt, should I credit you for the code I based my patch on?
cool-RR commentedon Oct 3, 2024
Hey, I'm the guy who originally suggested
strictforzip. I was just usingmapand wanting the same feature there, which prompted me to find this issue. I too am +1 on implementing it. If you do implement it, I'll be happy to write the documentation.nineteendo commentedon Oct 3, 2024
That would be much appreciated, although encukou doesn't think an example is necessary.
cool-RR commentedon Oct 3, 2024
I see the documentation now, I agree an example isn't required. Good job.
dg-pb commentedon Oct 3, 2024
This closes doors to another extension - adding keyword arguments to
map.Maybe it would be worth considering both at the same time and finding out what would be "joint optimum" to have performant & convenient solutions to both?:
a)
map(func, arg1, arg2, c=arg3).b)
map(func, arg1, arg2, strict=True).What about achieving
map(func, arg1, arg2, c=arg3, strict=True)?Of course, one can always convert
funcinto positional only version for this, but I expect performance penalty for doing so is going to be much larger than performance benefit ofmap(..., strict)vsstartmap(..., zip(..., strict))Or is there a reason why adding
keywordsis out of the question?3 remaining items
gh-119793: Add optional length-checking to `map()` (GH-120471)
encukou commentedon Nov 4, 2024
Merged! Thank you @nineteendo for your work and patience, and thanks to all the reviewers who chimed in.
cool-RR commentedon Nov 4, 2024
Congratulations @nineteendo , @encukou and all reviewers for delivering this feature! I can't wait to use it.
pythongh-119793: Prefer `map(..., strict=True)` over starmap/zip in e…
pythongh-119793: Prefer `map(..., strict=True)` over starmap/zip in e…
terryjreedy commentedon Nov 4, 2024
The open doc followup issue looks like a no-brainer, but needs review and verification.
gh-119793: Prefer `map(..., strict=True)` over starmap/zip in examples (
vstinner commentedon Nov 5, 2024
I merged the doc PR.
pythongh-119793: Add optional length-checking to `map()` (pythonGH-12…
pythongh-119793: Prefer `map(..., strict=True)` over starmap/zip in e…
pythongh-119793: Add optional length-checking to `map()` (pythonGH-12…
pythongh-119793: Prefer `map(..., strict=True)` over starmap/zip in e…