Skip to content

Instantly share code, notes, and snippets.

@quant61
Last active January 20, 2018 13:34
Show Gist options
  • Save quant61/30b54975bda0d0da496db478be3940ee to your computer and use it in GitHub Desktop.
Save quant61/30b54975bda0d0da496db478be3940ee to your computer and use it in GitHub Desktop.

idea about variable inode(vnode)

it's like php's zval, but more compact and supports many types as primitives

vnode takes 16 bytes exactly 4 bytes is header 12 bytes - value

vnodes could be useful for big arrays of mixed values

header: 1st byte is reserved(to distinct it from other stuctures) 2st byte - type? 3st byte - length? 4st byte - extra?

  • vnode can be either object or primitive
  • object vnode have pointer to object(like object in php or js)
  • primitive vnode stores value in self(like primitives in php or js)

object vnode is just a pointer to an object

primitive vnode can store up to 8-12 bytes

  primitive types:
    some special values(like null, true, false...) - 1 type
    (u)int{8,16,32,64} - 8 types
    float(32/64) - 2 types
    small vectors(7 types, length specified in separate byte:
      float32 up to 3
      (u)int32 up to 3
      (u)int16 to 6
      (u)int8 to 12
    float32 complex
raw values:
  string up to 12 bytes
  binary up to 12 bytes
  msgpack(cbor, others...) value up to 12 bytes
  bits up to 96

tuples:
  32bit index +  64 bit value:
  index types:
    int
    str(up to 4 bytes)
    word(index in dictionary, 50k values in dictionary?)
    2D (u)int16(checkboard?)
    4D (u)int8(hypercheckboard?)
  value types:
    pointer to object
    pointer to vnode
    one of IEEE 754 numbers
    string|binary|bits|msgpack up to 8 bytes
    vector of IEEE 754 numbers up to 8 bytes

resource-like fast arrays:
  length(32bit)+pointer(64bit)
  type(specified in header):
    any of IEEE 754 number
    complex
    binary
    string
    bits
    array of vnodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment