flextablev0.1.0

What's New in 0.1.0

The first release: the table type, its sequence and traversal library, and the performance work behind it.

flextable 0.1.0 is the first release. It ships the complete table type, a sequence and traversal library, and a round of low-level performance work. The crate is free of unsafe code and has one dependency, hashbrown.

Highlights#

  • Table: one shared, nestable container for sequences, records, dictionaries and sets.
  • Sequence library: push, pop, insert, remove, concat, pack, unpack, move_within, move_to, sort, sort_by, reverse.
  • Traversal: pairs, ipairs and an O(1) next, all safe to use while clearing fields, with a deterministic order.
  • Zero-clone reads: borrow() returns a TableRef whose get and iter return references, plus get_integer, get_number and get_bool.
  • Copies: shallow copy() and a cycle-safe deep_clone() that preserves shared sub-tables.
  • table! macro for literal construction.

Performance#

The table keeps integer keys 1..=n in an array and everything else in an insertion-ordered hash part, so len() is O(1), appends are a vector push, and lookups never allocate. Hot paths were then tuned at the machine-code level. On small, in-cache tables (ns per operation, i5-1240P):

OperationBefore tuning0.1.0
set(i) overwrite6.51.1
pop~8~1
pairs() per field19.84.7
record set, string key10.17.8
sort floats, per element31.512.1
sort strings, per element55.737.0

Full numbers and comparisons with Vec and HashMap are on the Performance page.

Quality#

  • 40 tests: unit, integration and doc tests, including randomized runs that compare a table against a plain HashMap and Vec over thousands of operations.
  • CI on Linux and Windows with rustfmt and clippy -D warnings.
  • Every example in these docs is compiled and run.

Not in this release#

Metatables, weak tables and function values are not implemented. See Coming from Lua for every difference from Lua tables.

Upgrading#

There is nothing to upgrade from. To start, see Installation.