GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-128335: Make slice generic at runtime by Gobot1234 · Pull Request #128336 · python/cpython

Conversation

@Gobot1234

@Gobot1234 Gobot1234 commented Dec 29, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Make slice generic #128335

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

obskyr and Jackenmen reacted with thumbs up emoji adamjstewart reacted with heart emoji adamjstewart reacted with rocket emoji
All reactions
  • 👍 2 reactions
  • ❤️ 1 reaction
  • 🚀 1 reaction
@Gobot1234
Make slice generic
6baf878
@bedevere-app bedevere-app Bot mentioned this pull request Dec 29, 2024
Make slice generic #128335
Closed
@bedevere-app bedevere-app Bot added the awaiting review label Dec 29, 2024
@Gobot1234
Add associated test
61fbf37
@Gobot1234
Gobot1234 marked this pull request as draft December 29, 2024 21:31
@bedevere-app bedevere-app Bot removed the awaiting review label Dec 29, 2024
@blurb-it
📜🤖 Added by blurb_it.
f241643
@Gobot1234
Gobot1234 marked this pull request as ready for review December 29, 2024 21:38
@bedevere-app bedevere-app Bot added the awaiting review label Dec 29, 2024
decorator-factory
decorator-factory reviewed Dec 29, 2024
View reviewed changes
Comment thread Objects/sliceobject.c
METH_O, slice_indices_doc},
{"__reduce__", (PyCFunction)slice_reduce,
METH_NOARGS, reduce_doc},
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"},

@decorator-factory decorator-factory Dec 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docstring seems misleading, as PEP 585 doesn't mention the slice class.

(Maybe PEP 585 could refer to https://typing.readthedocs.io/en/latest/guides/modernizing.html#generics-in-the-typing-module? Right now it links to documentation for __class_getitem__ that on its own isn't a replacement for PEP 585 from a reader's perspective)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Gobot1234 Gobot1234 Dec 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it is maybe a little silly to be putting PEPs in these things when they aren't active docs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood Dec 29, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRs to the PEPs repo improving things like this are welcome!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Gobot1234 Gobot1234 Dec 29, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if @AlexWaygood / @JelleZijlstra have opinions on this. This is done in other places. I seem to have time travelled here

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood Dec 30, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree that our docstrings probably also shouldn't be referencing PEPs, which are, as you both note, historical documents recording decisions that were made at one point in time rather than living documentation. But all the other __class_getitem__ docstrings say this currently, so I think it makes sense to follow suit here and change all the __class_getitem__ docstrings to something better all at once as a followup

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gobot1234 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
JelleZijlstra
JelleZijlstra reviewed Dec 30, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2024-12-29-21-33-08.gh-issue-128334.3c5Nou.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Gobot1234 and others added 2 commits December 30, 2024 17:11
@Gobot1234 @JelleZijlstra
Update Misc/NEWS.d/next/Core_and_Builtins/2024-12-29-21-33-08.gh-issu…
112d407
…e-128334.3c5Nou.rst

Co-authored-by: Jelle Zijlstra <[email protected]>
@Gobot1234
Update 2024-12-29-21-33-08.gh-issue-128334.3c5Nou.rst
60a9c08
@Gobot1234
Gobot1234 requested review from AlexWaygood and JelleZijlstra March 11, 2025 16:25
@obskyr obskyr mentioned this pull request Mar 20, 2025
Make the built-in slice type generic in terms of its start, stop, and step python/typeshed#10174
Closed
@brianschubert

brianschubert commented Apr 18, 2025

Copy link
Copy Markdown
Contributor

I think this calls for a whatsnew entry. Something like

* The :class:`slice` type now supports subscription,
  making it a :term:`generic type`.
  (Contributed by James Hilton-Balfe in :gh:`128335`.)

We should probably also add a versionchanged to the docs noting that slice is now a generic type.

JelleZijlstra, Gobot1234, and adamjstewart reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Gobot1234
Merge branch 'main' into patch-4
b8b2d20
JelleZijlstra
JelleZijlstra approved these changes May 4, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 4, 2025
@JelleZijlstra

JelleZijlstra commented May 4, 2025

Copy link
Copy Markdown
Member

This looks good to me but agree it needs to be documented.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gobot1234 added 3 commits October 14, 2025 16:20
@Gobot1234
Merge branch 'main' into patch-4
ba15ed9
@Gobot1234
Add more docs
7a95cc9
@Gobot1234
Merge remote-tracking branch 'origin/patch-4' into patch-4
c7991b3
@Gobot1234
Gobot1234 requested review from AA-Turner and willingc as code owners October 14, 2025 15:25
@Gobot1234
oops that probably doesn't work
4da9842
@Gobot1234 Gobot1234 mentioned this pull request Oct 14, 2025
Links to PEP 585 in Generic types #140121
Closed
@Gobot1234
Fix documentation typo
21e8ee8
@Gobot1234
Gobot1234 requested a review from JelleZijlstra January 7, 2026 12:18
@Gobot1234
Merge branch 'main' into patch-4
768ab89
JelleZijlstra
JelleZijlstra reviewed Jan 8, 2026
View reviewed changes
Comment thread Doc/reference/datamodel.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Gobot1234 @JelleZijlstra
Update Doc/reference/datamodel.rst
ccb638c
Co-authored-by: Jelle Zijlstra <[email protected]>
JelleZijlstra
JelleZijlstra approved these changes Jan 11, 2026
View reviewed changes
@JelleZijlstra
JelleZijlstra merged commit 265381b into python:main Jan 11, 2026
46 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 11, 2026
reidenong pushed a commit to reidenong/cpython that referenced this pull request Jan 12, 2026
@Gobot1234 @JelleZijlstra @reidenong
pythongh-128335: Make slice generic at runtime (python#128336)
72bbb0f
Co-authored-by: Jelle Zijlstra <[email protected]>
adamjstewart
adamjstewart reviewed Jan 18, 2026
View reviewed changes
Comment thread Doc/reference/datamodel.rst
.. versionadded:: 3.15

The :func:`slice` type now supports :ref:`subscription <subscriptions>`. For
example, ``slice[float]`` may be used in type annotations to indicate a slice

@adamjstewart adamjstewart Jan 18, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is something like slice[float, float, int] also supported? This is necessary for, e.g., pandas.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood Jan 18, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that should work fine. The number of arguments passed in isn't usually checked at runtime.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adamjstewart reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@Gobot1234 @JelleZijlstra @thunder-coding
pythongh-128335: Make slice generic at runtime (python#128336)
fa31f9b
Co-authored-by: Jelle Zijlstra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@willingc willingc Awaiting requested review from willingc willingc is a code owner
+2 more reviewers
@adamjstewart adamjstewart adamjstewart left review comments
@decorator-factory decorator-factory decorator-factory left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@Gobot1234 @brianschubert @JelleZijlstra @adamjstewart @decorator-factory @AlexWaygood
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.