Python mode

() [] {} , : ` = ; @ .  # Note that @ and . require the proper context.
 
1
# Literals
2
1234
3
0.0e101
4
.123
5
0b01010011100
6
0o01234567
7
0x0987654321abcdef
8
7
9
2147483647
10
3L
11
79228162514264337593543950336L
12
0x100000000L
13
79228162514264337593543950336
14
0xdeadbeef
15
3.14j
16
10.j
17
10j
18
.001j
19
1e100j
20
3.14e-10j
21
22
23
# String Literals
24
'For\''
25
"God\""
26
"""so loved
27
the world"""
28
'''that he gave
29
his only begotten\' '''
30
'that whosoever believeth \
31
in him'
32
''

Cython mode

22
 
1
2
import numpy as np
3
cimport cython
4
from libc.math cimport sqrt
5
6
@cython.boundscheck(False)
7
@cython.wraparound(False)
8
def pairwise_cython(double[:, ::1] X):
9
    cdef int M = X.shape[0]
10
    cdef int N = X.shape[1]
11
    cdef double tmp, d
12
    cdef double[:, ::1] D = np.empty((M, M), dtype=np.float64)
13
    for i in range(M):
14
        for j in range(M):
15
            d = 0.0
16
            for k in range(N):
17
                tmp = X[i, k] - X[j, k]
18
                d += tmp * tmp
19
            D[i, j] = sqrt(d)
20
    return np.asarray(D)
21
22

Configuration Options for Python mode:

Advanced Configuration Options:

Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help

MIME types defined: text/x-python and text/x-cython.