Skip to content
Advertisement

Tag: counting

Tracking how many elements processed in generator

I have a problem in which I process documents from files using python generators. The number of files I need to process are not known in advance. Each file contain records which consumes considerable amount of memory. Due to that, generators are used to process records. Here is the summary of the code I am working on: My process_records function

Fast way of counting non-zero bits in positive integer

I need a fast way to count the number of bits in an integer in python. My current solution is but I am wondering if there is any faster way of doing this? PS: (i am representing a big 2D binary array as a single list of numbers and doing bitwise operations, and that brings the time down from hours

Advertisement