Skip to content
Advertisement

Slicing a list in Python without generating a copy

I have the following problem. Given a list of integers L, I need to generate all of the sublists L[k:] for k in [0, len(L) – 1], without generating copies. How do I accomplish this in Python? With a buffer object somehow? Answer The short answer Slicing lists does not generate copies of the objects in the list; it just

Implementing a function in Python vs C

Is there a difference (in terms of execution time) between implementing a function in Python and implementing it in C and then calling it from Python? If so, why? Answer Python (at least the “standard” CPython implementation) never actually compiles to native machine code; it compiles to bytecode which is then interpreted. So a C function which is in fact

tokenize in python3.x

I have following codes in python2.x: Now problem is that in python3.x second argument does not exist. I need to call the function operations.eat() before tokenize. How can we perform the above task in python3.x. One idea is to directly call the function tokenize.eat() before ‘tokenize’ statement(last line of the code). But I am not sure about the arguments to

Advertisement