Python Slot Machine

  
Latest version

Released:

Python can’t just allocate a static amount of memory at object creation to store all the attributes. In 3 used 0.2305 MiB RAM in 0.12s, peaked 0.00 MiB above current, total RAM usage 15.80 MiB In 4: from slots. If you go in the main entrance, pass the centrifuge lounge and poker lounge, when you get to an area os slots, they should be on your left against the wall near the restrooms. Sort of loud and annoying. But it is monty python.

Simple, expandable, customizable slot machine

Monty Python Slot Machines Jackpot

Project description

Simple, expandable, customizable slot machine

pip install slotmachine

Release historyRelease notifications RSS feed

0.0.3.8

0.0.3.3

Slot Machine Programming Code

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Slot
Files for slotmachine, version 0.0.3.8
Filename, sizeFile typePython versionUpload dateHashes
Filename, size slotmachine-0.0.3.8.tar.gz (3.2 kB) File type Source Python version None Upload dateHashes

Monty Python Slot Machine For Sale

Python Slot MachineClose

Monty Python Slots Online

Hashes for slotmachine-0.0.3.8.tar.gz

Hashes for slotmachine-0.0.3.8.tar.gz
AlgorithmHash digest
SHA256c08002cd6e5f844935573552f680b4504d502fc7d9328ad6e298a2205595cc91
MD54c8d1d4408c73b58f94b2e0448f1e67d
BLAKE2-25645133559836cd2182592a1789622b03bc4d76aa1137ea6d293fa0902a1e5b950
Python

In Python every class can have instance attributes. By default Pythonuses a dict to store an object’s instance attributes. This is reallyhelpful as it allows setting arbitrary new attributes at runtime.

However, for small classes with known attributes it might be abottleneck. The dict wastes a lot of RAM. Python can’t just allocatea static amount of memory at object creation to store all theattributes. Therefore it sucks a lot of RAM if you create a lot ofobjects (I am talking in thousands and millions). Still there is a wayto circumvent this issue. It involves the usage of __slots__ totell Python not to use a dict, and only allocate space for a fixed setof attributes. Here is an example with and without __slots__:

Without__slots__:

Machine

With__slots__:

The second piece of code will reduce the burden on your RAM. Some peoplehave seen almost 40 to 50% reduction in RAM usage by using thistechnique.

On a sidenote, you might want to give PyPy a try. It does all of theseoptimizations by default.

Monty Python Slot Machine App

Slot

Python Slots Class

Below you can see an example showing exact memory usage with and without __slots__ done in IPython thanks to https://github.com/ianozsvald/ipython_memory_usage