cython

Форк
0
/
disabled_annotations.py 
33 строки · 890.0 Байт
1
import cython
2

3
@cython.annotation_typing(False)
4
def function_without_typing(a: int, b: int) -> int:
5
    """Cython is ignoring annotations in this function"""
6
    c: int = a + b
7
    return c * a
8

9

10
@cython.annotation_typing(False)
11
@cython.cclass
12
class NotAnnotatedClass:
13
    """Cython is ignoring annotatons in this class except annotated_method"""
14
    d: dict
15

16
    def __init__(self, dictionary: dict):
17
        self.d = dictionary
18

19
    @cython.annotation_typing(True)
20
    def annotated_method(self, key: str, a: cython.int, b: cython.int):
21
        prefixed_key: str = 'prefix_' + key
22
        self.d[prefixed_key] = a + b
23

24

25
def annotated_function(a: cython.int, b: cython.int):
26
    s: cython.int = a + b
27
    with cython.annotation_typing(False):
28
        # Cython is ignoring annotations within this code block
29
        c: list = []
30
    c.append(a)
31
    c.append(b)
32
    c.append(s)
33
    return c
34

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.