picrin-scheme / picrin

lightweight scheme interpreter
MIT License
414 stars 35 forks source link

Optimize records to use vector rather than a dict for field storage. #324

Closed dcurrie closed 8 years ago

dcurrie commented 8 years ago

This changes the C API for records to use integer indices into the record rather than field names. This makes records smaller, and accesses faster. The slight drawback is that it's harder to use Scheme records from C, but perhaps data values are better for this purpose anyway,

KeenS commented 8 years ago

I like it. I was thinking to rewrite to use vectors too but didn't have time.

@wasabiz How do you think? Do you care about API compatibility of records?

nyuichi commented 8 years ago

@dcurrie @KeenS

I just changed the C APIs in a different way. Record has now only one single cell and the internal representation of fields is customizable from scheme. For now I leave the representation unchanged to avoid regression, but if you update this patch, I'll merge then.

dcurrie commented 8 years ago

OK, I've modified contrib/20.r7rs/scheme/base.scm to adapt the new C APIs.

nyuichi commented 8 years ago

Beautiful!