Python vs. C++11
sturlamolden
sturlamolden at yahoo.no
Sun Feb 12 22:21:40 EST 2012
There are bigsimilarities between Python and the new C++ standard. Now
we can actually use our experience as Python programmers to write
fantastic C++ :-)
Here is a small list of similarities to consider:
Iterate over any container, like Python's for loop:
for (type& item: container)
Pointer type with reference counting:
std::shared_ptr
Python-like datatypes:
tuple std::tuple
list std::vector
std::list
std::stack
dict std::unordered_map
set std::unordered_set
complex std::complex
deque std::deque
lambda [name](params){body}
heapq std::heap
weakref weak_ptr
str std::string -- unicode, raw strings, etc work as Python
Other things of interest:
std::regex, std::cmatch
std::thread thread api versy similar to Python's
std::atomic datatype for atomic operations
std::mt19937 same prng as Python
More information about the Python-list
mailing list