precompute

Pythonic way to only do work first time a variable is called

Hello, my Python class has some variables that require work to calculate the first time they are called. Subsequent calls should just return the precomputed value. I don't want to waste time doing this work unless they are actually needed by the user. So is there a clean Pythonic way to implement this use case? My initial thought was ...

guidance on precomputed SQL attributes

Often I deal with aggregate or parent entities which have attributes derived from their constituent or children members. For example: The byte_count and packet_count of a TcpConnection object is computed from the same attributes of its two constituent TcpStream objects, which in turn are computed from their constituent TcpPacket objec...

Comparing string distance based on precomputed hashes

I have a large list (over 200,000) of strings that I'd like to compare to a given string. The given string is inserted by a user, so it may be slightly incorrect. What I was hoping to do was create some kind of precomputed hash on each string on adding it to the list. This hash would contain information such as string length, addition...