Disclaimer: below is generated after I found a performance issue using python in rhino 9.
Rhino 9 SR0 2026-9-8 (Rhino 9 BETA, 9.0.26251.12303, Git hash:master @ 72abdb206ba34beb503dd9f4cb04ffa57568edd2)
License type: Commercial, build 2026-09-08
License details: Cloud Zoo
Expires on: 2026-10-23
Windows 11 (10.0.26200 SR0.0) or greater (Physical RAM: 64GB)
.NET 10.0.2
A script of mine that draws ~8,400 curves and ~780 groups takes 32 s in a fresh session. Undo it, run it again, and it takes 115 s. Phase timers put all 86 seconds of the difference in one place: creating groups. Curve creation, attributes and user strings are unaffected.
Narrowing it down, in one document, moments apart:
Groups.Add() alone 134.66 ms each
Groups.AddToGroup(...) 0.018 ms each
So it’s Add(), not putting objects in the group. And the deciding measurement — same document, same group table:
Groups.Add("explicit name") 0.010 ms each
Groups.Add() 135.495 ms each
Passing a name makes it instant. rs.AddGroup() is the same no-name call and is equally slow, so it isn’t a rhinoscriptsyntax issue.
It isn’t group table size either. Fresh session, 6,051 groups in the table: 200 groups in 0.136 s. After running the script and undoing it, 7,026 groups: 200 groups in 26.5 s. A 16% change in table size, a 195-fold change in time.
Minimal repro:
import time, Rhino, scriptcontext as sc
doc = sc.doc
def bench(tag):
t = time.time()
for _ in range(200):
doc.Groups.Add()
print("%s: %.3f s for 200, groups=%d" % (tag, time.time()-t, doc.Groups.Count))
bench("before")
# now run anything that adds a few thousand objects and a few hundred groups,
# then Ctrl+Z it
bench("after undo")
Deleting the previous run’s objects instead of undoing them does not trigger it — timings stay at the fresh figures. It’s specifically undo.
My guess is that auto-naming searches for an unused group name and that search degrades once the table holds an undone run’s groups, but that’s inference; the measurements above are what I can stand behind.
Workaround for anyone hitting this: pass an explicit unique name to Groups.Add().