Cairo Dictionaries
Overview
Guide correct creation and use of Cairo dictionaries with proper ownership and performance notes.
Quick Use
- •Read
references/dictionaries.mdbefore answering. - •Show minimal snippets using
Felt252DictplusFelt252DictTraitmethods. - •Mention squashing and cost implications when discussing performance.
Response Checklist
- •Use
Felt252Dict::<T>::default()to initialize. - •Use
insertandgetfor basic operations; useentry/finalizefor advanced patterns. - •Remind that keys are
felt252and values are genericT. - •Call out that dictionary access is linear in the number of entries and squashing occurs on destruction.
Example Requests
- •"How do I store balances by address in Cairo?"
- •"Why does
getreturn a default value sometimes?" - •"What is dictionary squashing and when does it happen?"