All Questions
Tagged with data-structures python
27 questions
4
votes
1
answer
2k
views
Text adventure game: is there a more elegant way to store data & control logic?
so for the past several months, I've been working on a personal project. It's a comically large, highly open, handcrafted text adventure game packed with inside jokes and fun little surprises for my ...
2
votes
1
answer
428
views
Should a data class manipulate its input?
Background
I'm a scientist and trying to incorporate better software development practices in my work. In my niche field there's a standard model everyone uses that accepts a whopping 56 arguments. I'...
0
votes
2
answers
89
views
Restructuring a “processing slip” like object used in many steps
I have worked on a library which processed data through multiple steps. It was written in R, a dynamic programming language where one could just add fields to existing “objects”, which were just ...
0
votes
3
answers
797
views
Which is the best data structure to use when you want to randomly pick elements & use them, but also delete them after use
I have 1000 lines in a text file. I want to read them into some data structure[DS].
After reading them, I will be randomly picking 50 lines from the DS (using a Random Number Generator). Next time 50 ...
7
votes
1
answer
3k
views
Python: Class vs NamedTuple vs Hybrid vs DataClass
So all four of these approaches to structure data on their surface work more or less the same to keep data well structured.
Are there any reasons, be they hidden performance issues/enhancements, ...
0
votes
1
answer
3k
views
What is the space complexity of a Python dictionary?
If python dictionaries are essentially hash tables and the length of hashes used in the python dictionary implementation is 32 bits, that would mean that regardless of the number of key-value pairs ...
0
votes
0
answers
93
views
Is it idiomatic to use protobufs as containers within a service?
I love gRPC, but I find every step of the protobuf process rather frustrating (particularly in Python). Even though they are structurally similar to data structures composed of lists and dicts, you ...
1
vote
1
answer
1k
views
Designing an Entity Component System for interfacing with a scripting language
I am currently building an Entity Component System (ECS) in cython in order to speed up operating on large numbers of game objects in python. In the process of building this system, I ran into the ...
11
votes
4
answers
827
views
Good code style to introduce data checks everywhere?
I have a project that is sufficiently large in size that I can't keep every aspect in my head any more. I'm dealing with a number of classes and functions in it, and I'm passing data around.
With ...
-1
votes
2
answers
205
views
Creating instances of an ability when there are multiple different type of abilities
I'm creating an RPG game where a player has a set of skills, each of which he can level up to improve its effect. Here are two example skills:
health: increase player's maximum health
regeneration: ...
1
vote
1
answer
327
views
Best structuring for IRC message decoding (Python)
I am writing a simple IRC chatbot in Python and, in an effort to get more into OOP, made a basic "connection" class that manages all the backing-and-forthing involved. But IRC protocol is rather ...
6
votes
2
answers
5k
views
Sort a list while putting together or after?
I have to read through an extremely large amount of network data from various log files, and compile relevant information about that data to perform statistical analysis on it (the top communicators, ...
1
vote
1
answer
152
views
How to represent alternative and sequential tasks?
I am experimenting with hierarchical task planning (in python) and I would like to have functions which return lists of tasks. I need to differentiate between alternative paths and sequential tasks. ...
4
votes
2
answers
3k
views
Complex data structure in python: just dict, etc, or some classes?
Consider a web service API that returns a complex Json object. Using the stock Python tools for the job, this will read in from the web service as a dict which contains, in turn, a mixture of arrays, ...
1
vote
2
answers
216
views
Efficient datastructure to create size-limited dictionary
I need a class that acts like a dictionary but will constrain the total number of key/value pairs it contains. For instance, let's say the maximum number of entries is 1000 and the class already ...