Pyupgrade to Python 3.9 (#4718)

* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2021-09-07 13:37:03 +02:00
committed by GitHub
parent 5d5831bdd0
commit cecf43d648
142 changed files with 523 additions and 530 deletions

View File

@ -3,10 +3,10 @@ Python program for Bitonic Sort.
Note that this program works only when size of input is a power of 2.
"""
from typing import List
from __future__ import annotations
def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) -> None:
def comp_and_swap(array: list[int], index1: int, index2: int, direction: int) -> None:
"""Compare the value at given index1 and index2 of the array and swap them as per
the given direction.
@ -37,7 +37,7 @@ def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) ->
array[index1], array[index2] = array[index2], array[index1]
def bitonic_merge(array: List[int], low: int, length: int, direction: int) -> None:
def bitonic_merge(array: list[int], low: int, length: int, direction: int) -> None:
"""
It recursively sorts a bitonic sequence in ascending order, if direction = 1, and in
descending if direction = 0.
@ -61,7 +61,7 @@ def bitonic_merge(array: List[int], low: int, length: int, direction: int) -> No
bitonic_merge(array, low + middle, middle, direction)
def bitonic_sort(array: List[int], low: int, length: int, direction: int) -> None:
def bitonic_sort(array: list[int], low: int, length: int, direction: int) -> None:
"""
This function first produces a bitonic sequence by recursively sorting its two
halves in opposite sorting orders, and then calls bitonic_merge to make them in the