All Questions
Tagged with performance range
56
questions
-1
votes
2
answers
110
views
Fastest way to generate numbers up to a range in Python
I want to create a list of numbers that contains three consecutive 1s in its binary representation. To do this, I make set of number up to 2**n, and subtract it with a set of numbers that contains NO ...
1
vote
2
answers
246
views
Counting Nested Ranges
With N ranges of the form [start, end] (both endpoints inclusive), I want to find, for each range, how many (other) ranges contain it and how many ranges it contains (are contained by it).
tl;dr count ...
1
vote
1
answer
74
views
Why is ClosedRange<Int>.contains 3.4 million times slower than expected?
The contains method in a ClosedRange in Swift seems very slow.
I create the following Swift Playground on macOS for testing:
import Foundation
func measure(fn: @escaping ()->Void) -> ...
-3
votes
2
answers
192
views
Python for loop: array unpacking vs range deconstruction
I'm following a data structures and algorithms course taught in Python at the moment and the instructor always opts to unpack arrays (well, lists) using a range functions (method 2 below) instead of ...
2
votes
2
answers
321
views
The fastest way to get all permutations of a range without having consecutive neighbours in python
I want to get all permutations of any range with length n, starting from 0 and ending on n (range(n)) that don't have consecutive numbers.
Example: [0,1,2,3,4]
There the permutations should look like ...
0
votes
1
answer
81
views
Most efficient way to operate basic calculations based on parts of other sheets? (Excel VBA)
My goal is to use parts of several sheets to compute basic stuff of each of the selected rows in those sheets.
The prior way to do this was to create a row with formulas manually. Let's say I have ...
0
votes
2
answers
67
views
calculate mean (or uniquely mark) groups that match critearia
This goes back to a question I've asked some time ago - I'm still struggling in the same area.
I have a data.table with some values ('value'), lower limits ('min_val') and upper limits ('max_val'):
...
0
votes
2
answers
145
views
Strange speeds of `x in range(...)` checks
With r = range(1500, 2500), I benchmarked x in r for x below/in/above the range:
1000 in r : 58 ns ± 0 ns
2000 in r : 101 ns ± 1 ns
3000 in r : 58 ns ± 0 ns
Checking 1000 is faster than checking ...
0
votes
1
answer
229
views
range1.value = range2.value Very slow VBA
I'am writing simple code like nextCell.Value = dateJour.Value, were dateJour is a date located in a cell in the workbook.
When I loop (about 100 times) it takes forever because each nextCell.Value = ...
0
votes
1
answer
270
views
Is there any downside to iterating over a range for more times than is required to generate desired output?
I'm taking a 100 Days of Code in Python, and I'm trying to create a Python password generator by taking in user input for how many letters, numbers, and symbols they'd like in their password.
The ...
0
votes
2
answers
46
views
Creating a List of a Range is slow, are there alternatives? [closed]
so I have to create a List of a big range and am trying to accomplish this with list(range(number1, number2))and the numbers number1 and number2 can have a big difference, for example 235 and ...
6
votes
7
answers
703
views
Count number of rows within certain range
I have a data.table with some values ('value'), lower limits ('min_val') and upper limits ('max_val'):
| value | min_val | max_val |
1: | 94.001 | 94.00 | 94.02 |
2: | 94.002 | 94.00 | 94.03 |
3: | ...
2
votes
2
answers
305
views
Adding ranges to count overlap python
I have a list of ranges. I now would like to compute a dictionary key : value, where key is the number and value is in how many of those ranges the number exists.
A bad way to compute this is:
from ...
-2
votes
2
answers
57
views
Time to excecute function goes up instead of down instead of up as x increases - Range()
My bad if this is a bit nooby or I don't understand how this works. I'm trying to get the time of range(1,x) using the code below.
Code
import timeit
def main(x):
return range(1,x)
def timeThem(x):...
0
votes
1
answer
954
views
Algorithm for finding ranges which include a number
Say you have a "Range" type like this (pseudocode):
Range {
int lowerBound
int upperBound
}
And you have a collection of ranges, where ranges may overlap:
var ranges = [Range{2, 5}, ...