<s> """<STR_LIT>""" <EOL> from __future__ import print_function , absolute_import <EOL> from collections import OrderedDict <EOL> import numpy as np <EOL> from numba import njit <EOL> from numba import jitclass <EOL> from numba import int32 , deferred_type , optional <EOL> from numba . runtime import rtsys <EOL> node_type = deferred_type ( ) <EOL> spec = OrderedDict ( ) <EOL> spec [ '<STR_LIT:data>' ] = int32 <EOL> spec [ '<STR_LIT>' ] = optional ( node_type ) <EOL> @ jitclass ( spec ) <EOL> class LinkedNode ( object ) : <EOL> def __init__ ( self , data , next ) : <EOL> self . data = data <EOL> self . next = next <EOL> def prepend ( self , data ) : <EOL> return LinkedNode ( data , self ) <EOL> @ njit <EOL> def make_linked_node ( data ) : <EOL> return LinkedNode ( data , None ) <EOL> node_type . define ( LinkedNode . class_type . instance_type ) <EOL> @ njit <EOL> def fill_array ( arr ) : <EOL> """<STR_LIT>""" <EOL> head = make_linked_node ( <NUM_LIT:0> ) <EOL> for i in range ( <NUM_LIT:1> , arr . size ) : <EOL> head = head . prepend ( i ) <EOL> c = <NUM_LIT:0> <EOL> while head is not None : <EOL> arr [ c ] = head . data <EOL> head = head . next <EOL> c += <NUM_LIT:1> <EOL> def runme ( ) : <EOL> arr = np . zeros ( <NUM_LIT:10> , dtype = np . int32 ) <EOL> fill_array ( arr ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( arr ) <EOL> np . testing . assert_equal ( arr , np . arange ( arr . size , dtype = arr . dtype ) [ : : - <NUM_LIT:1> ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> runme ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( rtsys . get_allocation_stats ( ) ) </s>
