You signed in with another tab or window. Reload to refresh your
8000
session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bit objects carry heavyweight physical/virtual attribute wrappers #136
Every bit object stores two empty lists (physical and virtual) with nested attribute pairlists just to hold vmode = "boolean" and Length = n. This imposes measurable overhead on every bit allocation and length lookup:
object.size(bit(1L))
# 1520 bytes (vs 520 bytes with a flat scalar Length attribute — ~3x overhead)b<- bit(10L)
system.time(for (iin1:100000) length(b))
# ~0.52s (vs ~0.018s with a flat Length attribute — ~29x slower)
system.time(for (iin1:50000) bit(10L))
# ~0.35s (vs ~0.16s with a flat Length attribute — ~2.2x slower)
In a future release, bit objects could store Length directly as a flat attribute while keeping full backwards compatibility:
physical.bit() and virtual.bit() synthesize list(vmode = "boolean") and list(Length = attr(x, "Length")) lazily on demand (with physical<-.bit / virtual<-.bit only attaching extra storage if a caller sets custom non-default attributes).
length.bit() (and internal length lookups) check flat Length first and fall back to virtual$Length so external constructors such as ff:::as.bit.ff() continue to work without breaking.
Activity