Skip to main content

All Questions

Tagged with
-2 votes
0 answers
27 views

Quickly computing primes with python [duplicate]

I was solving this problem in Project Euler which asks for finding the 10,001st prime. Here's what I did: def is_prime(x): local_list = [i for i in range(1, x+1) if x % i == 0] if len(...
user26346636's user avatar
-2 votes
1 answer
67 views

Making Python code faster for large data sets

I am solving a problem on HackerEarth (full text can be found here): Bob has a playlist of songs, each song has a singer associated with it (denoted by an integer) Favourite singer of Bob is the one ...
user26346636's user avatar
0 votes
0 answers
23 views

Why is my IDF Python code running much slower than pyspark

I am creating IDF values and my python code runs much slower compared to the pyspark implementation (2+ hours for mine versus seconds) and I am interested why that is so. I know pyspark is Java based, ...
Caden's user avatar
  • 25
-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 ...
Kim Dong's user avatar
  • 161
0 votes
1 answer
70 views

"Preprocessing" a Python function, to avoid excess evaluation of conditional logic

I am writing some Python code that includes functions with two sets of parameters. The first set of parameters will be different every single time the function is called. The second set of parameters ...
Jack MacArthur's user avatar
0 votes
1 answer
91 views

How to make python code fast for minimization?

The following code for minimization of a mechanical system works with no error. However, it is slow and to me there are unnecessary steps or loops that make it heavy! Would you make comment, and ...
Amir H. Fatollahi's user avatar
0 votes
0 answers
50 views

Parallelization Optimization

I want to parallelize the shuffling and analyzing of decks. I tried many synchronization libraries to no avail. What should I do to increase efficiency? I have already tried finding other ...
Sny's user avatar
  • 101
-2 votes
1 answer
54 views

Queue from which first occurrences may be removed [closed]

I participated in an Amazon coding challenge, and one of the questions was a really simple one. To paraphrase: Develop a method to handle shopping carts that takes two inputs, items being the current ...
Gabriel Tkacz's user avatar
0 votes
2 answers
74 views

Why is the "set.union()" function much slower than the set union operator "|" in this code?

I have been revisiting my solution for https://adventofcode.com/2023/day/16. Here is my old code: from functools import cache from helper import directions_2d # [(0, 1), (-1, 0), (0, -1), (1, 0)] def ...
ultinvincible's user avatar
0 votes
0 answers
68 views

Monitoring asyncio ready queue in python

I'm optimizing the performance of a Python application that includes many non-blocking I/O operations, some of which involve making HTTP API calls. We use an asynchronous client for all I/O operations,...
Sumanth BBN's user avatar
3 votes
1 answer
86 views

np.repeat inplace solution to avoid memory reallocation

How can I assign np.repeat (or equivalent function) output to existing memory? (many numpy functions have an "out=" parameter to do this). This reassignment would be very useful because I ...
Miguel Montes's user avatar
0 votes
0 answers
118 views

SQLalchemy request is too slow

I'm having some difficulty understanding why one of my SQL request displayed below is taking me way too much time when it shouldn't. This SQL request take me about 400ms when the database only have ...
Kamigaku's user avatar
0 votes
0 answers
23 views

Addressing Resource Exhaustion and Connection Leakage in Python Monitoring Scripts

In managing a server environment, especially when deploying monitoring scripts, it's crucial to ensure efficient resource utilization and proper handling of connections. Here to discuss the ...
tia's user avatar
  • 1
2 votes
0 answers
42 views

Turtle graphics lag over time

I made an etch-a-sketch project on a Raspberry Pi 4b, using python3, with turtle. Turning rotary encoders, you draw a picture. The project works, but over time, the lines being drawn lag behind making ...
leoh Jones's user avatar
0 votes
1 answer
118 views

Hackerrank Movement Slots: Code OpOptimization

Im, trying to solve a hackerank problem, the problem is: A light plastic ball is bounced on a stationary wheel situated horizontally on a table. There are n equal sized slots arranged radially around ...
Geddez's user avatar
  • 19

15 30 50 per page
1
2 3 4 5
74