Skip to main content

All Questions

Tagged with
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 ...
johnnymcmike's user avatar
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'...
coney1's user avatar
  • 87
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 ...
Martin Ueding's user avatar
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 ...
user93353's user avatar
  • 441
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, ...
Coupcoup's user avatar
  • 220
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 ...
MShakeG's user avatar
  • 127
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 ...
DeusXMachina's user avatar
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 ...
CodeSurgeon's user avatar
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 ...
user7088941's user avatar
-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: ...
Mahi's user avatar
  • 406
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 ...
Hactar's user avatar
  • 115
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, ...
Ben Schwabe's user avatar
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. ...
tssch's user avatar
  • 113
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, ...
bmargulies's user avatar
  • 1,717
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 ...
sinθ's user avatar
  • 1,311

15 30 50 per page