File: pep_526.py

package info (click to toggle)
cython 0.29.32-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 15,028 kB
  • sloc: python: 67,518; ansic: 14,866; cpp: 1,340; xml: 1,031; makefile: 393; lisp: 206; sh: 137; sed: 11
file content (22 lines) | stat: -rw-r--r-- 634 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import cython

def func():
    # Cython types are evaluated as for cdef declarations
    x: cython.int               # cdef int x
    y: cython.double = 0.57721  # cdef double y = 0.57721
    z: cython.float = 0.57721   # cdef float z  = 0.57721

    # Python types shadow Cython types for compatibility reasons
    a: float = 0.54321          # cdef double a = 0.54321
    b: int = 5                  # cdef object b = 5
    c: long = 6                 # cdef object c = 6
    pass

@cython.cclass
class A:
    a: cython.int
    b: cython.int

    def __init__(self, b=0):
        self.a = 3
        self.b = b