processing / processing/libprocessing

Naming collision between Processing `map()` and Python `map()`

Open
#131 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
69
Forks
14
Avg merge
15d 22h
Merged PRs (30d)
3

Description

Trying to port the array example (See issue: Port Basics / Arrays / Array #3) and I'm running into this error:

coswave = [abs(cos(map(i, 0, width, 0, pi))) for i in range(width)]
                       ~~~^^^^^^^^^^^^^^^^^^^^
TypeError: 'int' object is not iterable

I suppose this is because Python has its own map() function (a list transformation) different from the map() function in Processing (a linear interpolation function).

Processing.py handles this by wrapping map() and dispatching based on the arguments (see source code). It uses the Processing version when called with five numeric arguments, and otherwise falls back to Python’s built-in. Note: the same approach is used for filter().

By contrast, py5 avoids the conflict by renaming the function to remap() instead.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the array example and the map() collision described in the issue, then compare the referenced processing.py dispatch in PAppletJythonDriver.java with py5's remap() API. Determine which naming or dispatch behavior libprocessing should adopt, and consider the Python built-in compatibility implications. Done means the chosen API resolves the example without ambiguity and is documented or tested accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.