File: cmp.pyx

package info (click to toggle)
cython 3.1.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,932 kB
  • sloc: python: 92,172; ansic: 19,275; cpp: 1,407; xml: 1,031; javascript: 511; makefile: 373; sh: 223; sed: 11
file content (101 lines) | stat: -rw-r--r-- 1,715 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
def single_py(a, b):
    """
    >>> single_py(1, 2)
    True
    >>> single_py(2, 1)
    False
    """
    return a < b

def cascaded_py(a, b, c):
    """
    >>> cascaded_py(1, 2, 3)
    True
    >>> cascaded_py(1, 2, -1)
    False
    >>> cascaded_py(10, 2, 3)
    False
    """
    return a < b < c

def single_c(int a, int b):
    """
    >>> single_c(1, 2)
    True
    >>> single_c(2, 1)
    False
    """
    return a < b

def cascaded_c(double a, double b, double c):
    """
    >>> cascaded_c(1, 2, 3)
    True
    >>> cascaded_c(1, 2, -1)
    False
    >>> cascaded_c(10, 2, 3)
    False
    """
    return a < b < c

def cascaded_mix_pyleft(a, double b, double c):
    """
    >>> cascaded_mix_pyleft(1, 2, 3)
    True
    >>> cascaded_mix_pyleft(1, 2, -1)
    False
    >>> cascaded_mix_pyleft(10, 2, 3)
    False
    """
    return a < b < c

def cascaded_mix_pyright(double a, double b, c):
    """
    >>> cascaded_mix_pyright(1, 2, 3)
    True
    >>> cascaded_mix_pyright(1, 2, -1)
    False
    >>> cascaded_mix_pyright(10, 2, 3)
    False
    """
    return a < b < c

def typed_cmp(list L):
    """
    >>> typed_cmp([1,2,3])
    False
    False
    False
    False
    """
    print L is Ellipsis
    print Ellipsis is L
    print 1 == L
    print L == 1.5

def pointer_cmp():
    """
    >>> pointer_cmp()
    True
    False
    True
    """
    cdef int* a = NULL
    cdef double* b = NULL
    cdef double** c = NULL
    print a is NULL
    print b is not NULL
    print c == NULL

def c_cmp(double a, int b, long c):
    """
    >>> c_cmp(1, 2, 3)
    True
    >>> c_cmp(1.5, 2, 2)
    True
    >>> c_cmp(1.5, 2, 0)
    False
    >>> c_cmp(1, 1, 3)
    False
    """
    return a < b <= c