struct
-like objects, i.e. ones that are largely the same as a Cstruct
instance, win in the memory department.- These tests do not try to determine what is best for very large sets of values, however; I direct the reader to http://stackoverflow.com/a/2670191 for an insight into that scenario when using a dictionary.
- Dictionaries beat out objects in access times.
- According to Wikipedia, the Python dictionary is highly optimised because it is used internally to implement namespaces. [citation needed]
import datetime | |
class EventTimer: | |
def __init__(self, name): | |
self.events = [] | |
self.timer = None | |
self.name = name | |
def reset(self): |
The purpose of this gist is to set up a virtual machine in such a way that the on-disk image in the host machine automatically grows and shrinks as needed by the guest machine. This utilizes the (still undocumented) "--discard" and "--nonrotational" parameters in "VBoxManage storageattach" which make the attached image appear as an SSD to the guest. Guest OS will then issue TRIM commands to the virtual controller where such an image is attached. VirtualBox is then able to capture the commands and punch holes in the attached VDIs.
Although there is some initial setup needed, I think the time saved with babysitting the VDIs is worth it. Usually you would need to zero out the free space with zerofree or sdelete and then run "VBoxManage --compact" on your images. With this setup you can allocate a large dynamic VDI (1TB or so) and it will keep itself at minimum size for easy syncing, backup, etc. You can also set it up in a template machine if you use one for clones etc.
- Linux
Download, but don't run, the Sierra installer from the Mac App Store. This places the installer at
/Applications/Install\ macOS\ Sierra.app/
.
Now run the following commands to build a suitable VM image from the installer:
git clone https://github.com/jonanh/osx-vm-templates
cd osx-vm-templates/packer
sudo ../prepare_iso/prepare_vdi.sh -D DISABLE_REMOTE_MANAGEMENT -o macOS_10.12.vdi /Applications/Install\ macOS\ Sierra.app/ .
-
Single-line comments are started with
//
. Multi-line comments are started with/*
and ended with*/
. -
C# uses braces (
{
and}
) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,