Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create and access frozenset with Boost Python

I have some C++ methods that have std::set<std::string> as argument or return value. I would like to map this to a Python frozenset (or regular set) but there does not seem to be a straightforward way to do this. Does anyone know how one may accomplish this task.

like image 509
Pim Schellart Avatar asked Nov 15 '22 03:11

Pim Schellart


1 Answers

Or you can use std::map<YourType, int> instead of std::set<YourType>, the value can be for example 0. std::map has the same insert/search time complexity as std::set, it also keeps the keys ordered, it will only bloat the memory a little. Then you can use map indexing suite and in python you can hide the difference in some wrapper class if needed. The disanvantage is that you have to modify your existing c++ code a little bit.

like image 132
Michel Samia Avatar answered Dec 14 '22 21:12

Michel Samia