Catalog · How the catalog works
FreePascal_PyCollections
Anyone may press Interesting, signed in or not. It helps others find this project.
README
PyCollections – Python‑style Collections for Free Pascal
PyCollections gives you Python‑like data structures in Free Pascal – dynamic lists, dictionaries, sets, and immutable versions.
Write cleaner, more expressive code without reinventing the wheel.
✨ Features
TPyList– dynamic array: append, insert, pop, sort (Timsort), reverse, slice, filterTPyDict– hash‑based dictionary:get,setdefault,pop, keys/values/itemsTPySet– unordered set with union, intersection, difference, subset testsTPyOrderedSet– set that remembers insertion orderTPyFrozenSet– immutable, hashable setTPyFrozenList– immutable list (tuple‑like)TPyOrderedDict– dict that preserves insertion orderTPyFrozenDict– immutable, hashable dict
All collections work with for … in loops.
🚀 Simple Example
program Contacts;
uses PyCollections;
var
names: TPyList;
scores: TPyDict;
begin
// Create a list and a dictionary
names := list(['Alice', 'Bob', 'Charlie']);
scores := dict(['Alice', 95, 'Bob', 87, 'Charlie', 92]);
WriteLn('Names: ', names.ToString);
WriteLn('Scores: ', scores.ToString);
// Add a new person
names.Append('Diana');
scores['Diana'] := 98;
WriteLn('Updated names: ', names.ToString);
WriteLn('Bob''s score: ', scores['Bob']);
// Clean up
names.Free;
scores.Free;
end.
