python / python/cpython

Consider cleanup of type for iterator variables bounded by asdl_seq_LEN

Open
#99,652 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-refactor
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

It looks like the asdl_seq_LEN macro's "return type" is Py_ssize_t. Throughout the code, the type of the variable compared against a value "returned" by the macro are variously

int or
Py_ssize_t

Pitch

I am not sure, but it seems like it would be good to be consistent throughout the code base. If this is something that seems reasonable or valuable, I would be happy to take on the task!

Previous discussion

No previous discussion, however I searched prior issues and see nothing noting something similar.

Contributor guide

Open the contributing guide

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 by locating the asdl_seq_LEN macro and reviewing its uses where iterator variables are compared with its result. Identify the affected variables typed as int or Py_ssize_t, then check the relevant existing tests after making the types consistent throughout the codebase.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.