Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Python 3.10, require Python >= 3.11 #2474

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

EwoutH
Copy link
Member

@EwoutH EwoutH commented Nov 9, 2024

Starting development for Mesa 3.1 and following SPEC 0 we can drop Python 3.10 support and require Python 3.11 or higher for future development. This allows adopting more modern Python features and simplifies the testing and CI configurations.

See the Python 3.11 release notes: https://docs.python.org/3/whatsnew/3.11.html

The 3.0.x release series will keep supporting Python 3.10.

image

Summary – Release highlights

Python 3.11 is between 10-60% faster than Python 3.10. On average, we measured a 1.25x speedup on the standard benchmark suite. See Faster CPython for details.

New syntax features:

New built-in features:

New standard library modules:

Interpreter improvements:

New typing features:

Important deprecations, removals and restrictions:

Starting development for Mesa 3.1 and following [SPEC 0](https://scientific-python.org/specs/spec-0000/) we can drop Python 3.10 support and require Python 3.11 or higher for future development. This allows adopting more modern Python features and simplifies the testing and CI configurations.

See the Python 3.11 release notes: https://docs.python.org/3/whatsnew/3.11.html

The 3.0.x release series will keep supporting Python 3.10.
@EwoutH EwoutH added the maintenance Release notes label label Nov 9, 2024
@EwoutH EwoutH added this to the v3.1 milestone Nov 9, 2024
@EwoutH
Copy link
Member Author

EwoutH commented Nov 9, 2024

@quaquel two things you might find cool we can start using when we require Python 3.11:

  1. Exception Notes (PEP 678)
    We could use add_note() to provide additional context for errors in Mesa. This would be particularly useful for:
  • Adding model state information when errors occur
  • Providing hints about common configuration mistakes
  • Adding contextual information about agent states

For example:

try:
    # Some model operation
except ValueError as e:
    e.add_note(f"Current model step: {self.steps}")
    e.add_note(f"Number of active agents: {len(self.agents)}")
    raise
  1. Self Type (PEP 673)
    We can use the new Self type annotation to better annotate methods that return instances of their own class, particularly useful in Agent and Model classes:
from typing import Self

class Agent:
    def clone(self) -> Self:
        return copy.deepcopy(self)

Those notes really seem handy!

Copy link

github-actions bot commented Nov 9, 2024

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -1.9% [-2.7%, -1.1%] 🔵 -0.4% [-0.6%, -0.3%]
BoltzmannWealth large 🔵 -2.0% [-2.5%, -1.5%] 🔵 -0.6% [-1.7%, +0.3%]
Schelling small 🔵 -0.4% [-0.9%, +0.1%] 🔵 +0.3% [-0.0%, +0.7%]
Schelling large 🔵 +0.4% [-0.7%, +1.4%] 🔵 +1.8% [+0.4%, +3.0%]
WolfSheep small 🔵 -0.3% [-0.8%, +0.1%] 🔵 +1.1% [+0.8%, +1.3%]
WolfSheep large 🔵 -6.2% [-9.7%, -2.9%] 🔵 -4.5% [-8.4%, -0.1%]
BoidFlockers small 🔵 +0.6% [-0.1%, +1.3%] 🔵 +0.3% [-0.5%, +1.1%]
BoidFlockers large 🔵 +0.3% [-0.5%, +1.2%] 🔵 +0.3% [-0.4%, +0.9%]

@EwoutH
Copy link
Member Author

EwoutH commented Nov 9, 2024

Not that this is not a breaking change by the way, because the requires-python = ">=3.11" prevents anyone from installing Mesa 3.1+ with Python 3.10 or lower. They still can install Mesa 3.0.x, which is fully compatible.

@EwoutH EwoutH merged commit b171136 into projectmesa:main Nov 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Release notes label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants