Skip to content

Automatically rename reserved properties - #673

Merged
hadley merged 10 commits into
mainfrom
prefix-special-attributes
Jun 8, 2026
Merged

hadley merged 10 commits into
mainfrom
prefix-special-attributes

Conversation

@hadley

@hadley hadley commented May 30, 2026

Copy link
Copy Markdown
Member

Implemented in C for performance

Fixes #579


Benchmark from claude

Ordinary-named properties (the common case)

Operation Before (min / median) After (min / median)
Foo(x = 1, y = 2) (construct) 66.7µs / 76.1µs 68.0µs / 77.7µs
f@x (get) 738ns / 902ns 779ns / 943ns
f@x <- 10 (set + validate) 38.0µs / 44.0µs 37.9µs / 44.0µs
prop<-(check = FALSE) (raw set) 328ns / 451ns 328ns / 410ns

All differences are within run-to-run noise.

Special-named properties (after)

Class Bar <- new_class("Bar", properties = list(names = class_character, y = class_numeric)):

Operation min / median
Bar(names = "a", y = 2) (construct) 62.6µs / 71.8µs
b@names (get) 738ns / 902ns
prop<-(check = FALSE) (raw set) 287ns / 410ns

The "_"-prefixed path is as fast as the ordinary path.

Implemented in C for performance

Fixes #579
@hadley hadley mentioned this pull request May 31, 2026
Comment thread src/prop.c
return name_sym;
}

SEXP prop_storage_rename_(SEXP names) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in C to avoid having to encode special names in C and R.

@hadley
hadley requested a review from t-kalinowski June 1, 2026 14:02
Comment thread R/class.R Resolved
Comment thread src/prop.c Resolved

@t-kalinowski t-kalinowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the one comment, everything else looks good!

@hadley
hadley merged commit ed21054 into main Jun 8, 2026
13 checks passed
@hadley
hadley deleted the prefix-special-attributes branch June 8, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow fallback method of storing properties for "forbidden" names

2 participants