Opened 3 years ago

Last modified 5 weeks ago

#29756 new task

Meta-ticket: Review of Python 3 features that sagelib should use systematically

Reported by: Matthias Köppe Owned by:
Priority: major Milestone: sage-9.8
Component: python3 Keywords: sd109
Cc: Frédéric Chapoton, Dima Pasechnik, John Palmieri, Tobias Diez, Travis Scrimshaw, Nicolas M. Thiéry, Samuel Lelièvre, Nils Bruin Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Matthias Köppe)

For Sage 9.7, all of the following features can be used:

Python 3.6 features (https://docs.python.org/3.10/whatsnew/3.6.html):

  • pathlib
  • static typing
    • #32058 add typing annotations in permutations
    • #32067 Developer manual: Section on typing annotations
    • #29775 Add a bit of typing to manifold code
    • #30381 Python 3 typing/protocols/ABCs
    • #30511 Type hints (__annotations__) and coercion/Cython
  • native namespace packages - #28925
  • yield from - #29857
  • f-strings (formatted strings)
  • keyword-only parameters (#16607, #31309)
  • new import machinery - #27074 (Make .sage modules importable)
  • __matmul__ (infix @ operator) - #22760
  • from ..a import b
  • ...?

Python 3.7 features (https://docs.python.org/3.10/whatsnew/3.7.html):

  • from __future__ import annotations (#31006)

Python 3.8 features (https://docs.python.org/3.10/whatsnew/3.8.html) can be used as soon as #32937 is merged:

Features introduced in Python 3.9 or later cannot be used in Sage yet because we support system Python 3.8.x.

Python 3.9 features (https://docs.python.org/3.10/whatsnew/3.9.html):

Python 3.10 features (https://docs.python.org/3.10/whatsnew/3.10.html):

Python 3.11 features (https://docs.python.org/3.11/whatsnew/3.11.html):

See also:

  • #29728: Meta-ticket: improve compatibility with the Python library
  • #30384: Adopt the “time window-based” policy for support of Python versions from NEP 29
  • #30551 Drop Python 3.6 support

Change History (43)

comment:1 Changed 3 years ago by Matthias Köppe

Cc: Tobias Diez added
Description: modified (diff)

comment:2 Changed 3 years ago by Eric Gourgoulhon

About types, has a general policy been discussed on sage-devel?

comment:3 Changed 3 years ago by Dima Pasechnik

typing is a standard Python 3 module, and it allows one to catch more errors.. Why would one have anything against it?

comment:4 in reply to:  3 Changed 3 years ago by Karl-Dieter Crisman

typing is a standard Python 3 module, and it allows one to catch more errors.. Why would one have anything against it?

Are there reasons (e.g. performance) not to use it in certain circumstances?

comment:5 Changed 3 years ago by Matthias Köppe

Cc: Travis Scrimshaw Nicolas M. Thiéry added

I created this ticket as a place for discussions of these new features to make sure that we use them systematically in the Sage library, rather than in an ad-hoc way.

For example, for typing, I think there are opportunities to integrate it with the various dynamically generated classes that come in from the category system, as I noted in #29775.

comment:6 Changed 3 years ago by Tobias Diez

There shouldn't be any performance issues with typing as it is deactivated on runtime (the only additional overhead is the import of the typing package). See also the discussion here https://realpython.com/python-type-checking/#pros-and-cons

comment:7 Changed 2 years ago by Matthias Köppe

Cc: Frédéric Chapoton added
Description: modified (diff)

comment:8 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:9 Changed 2 years ago by Samuel Lelièvre

Cc: Samuel Lelièvre added
Description: modified (diff)

comment:10 Changed 2 years ago by Samuel Lelièvre

Description: modified (diff)

comment:11 Changed 2 years ago by Samuel Lelièvre

Regarding f-strings, see this comment:

comment:12 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:13 Changed 2 years ago by Matthias Köppe

Cc: Nils Bruin added
Description: modified (diff)

comment:14 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:15 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:16 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:17 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:18 in reply to:  2 Changed 2 years ago by Markus Wageringel

Replying to egourgoulhon:

About types, has a general policy been discussed on sage-devel?

+1 for using typing. Return types in particular are useful for tab-completion on the result of function calls. For example

sage: "hello".upper().lower().upper()

this tab-completes without evaluating the code (i.e. without setting IPython's IPCompleter.greedy config option).

comment:19 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:20 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:21 Changed 2 years ago by Matthias Köppe

Milestone: sage-9.2sage-9.3

comment:22 Changed 2 years ago by Matthias Köppe

Cc: lelievre removed
Description: modified (diff)

comment:23 Changed 2 years ago by Markus Wageringel

Description: modified (diff)

comment:24 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:25 Changed 22 months ago by Matthias Köppe

Description: modified (diff)

comment:26 Changed 22 months ago by Matthias Köppe

Description: modified (diff)

comment:27 Changed 22 months ago by Matthias Köppe

Description: modified (diff)

comment:28 Changed 22 months ago by Matthias Köppe

Description: modified (diff)

comment:29 Changed 21 months ago by Matthias Köppe

Milestone: sage-9.3sage-9.4

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.

comment:30 Changed 20 months ago by Matthias Köppe

Description: modified (diff)

comment:31 Changed 20 months ago by Matthias Köppe

Description: modified (diff)

comment:32 Changed 18 months ago by Matthias Köppe

Description: modified (diff)

comment:33 Changed 18 months ago by Matthias Köppe

Description: modified (diff)

comment:34 Changed 17 months ago by Matthias Köppe

Description: modified (diff)

comment:35 Changed 17 months ago by Matthias Köppe

Milestone: sage-9.4sage-9.5

comment:36 Changed 12 months ago by Matthias Köppe

Milestone: sage-9.5sage-9.6

comment:37 Changed 8 months ago by Matthias Köppe

Milestone: sage-9.6sage-9.7

comment:38 Changed 7 months ago by Matthias Köppe

Description: modified (diff)

comment:39 Changed 7 months ago by Matthias Köppe

Description: modified (diff)

comment:40 Changed 7 months ago by Matthias Köppe

Description: modified (diff)

comment:41 Changed 7 months ago by Matthias Köppe

Description: modified (diff)

comment:42 Changed 3 months ago by Matthias Köppe

Milestone: sage-9.7sage-9.8

comment:43 Changed 5 weeks ago by Matthias Köppe

Description: modified (diff)
Note: See TracTickets for help on using tickets.