python-cookbook-in-modern-cpp

Writing python cookbook in Modern C++ (C++17)

Stars
9

python-cookbook-in-modern-cpp

Welcome to python-cookbook-in-modern-cpp repo! This repo is to attempt to write python-cookbook code in modern C++.

Env

macOS Sierra / clang 6.0 CentOS 7.3 / gcc 7.2

Dependencies

  • range-v3
    • Lazy evaluation and range algorithims to write python generator like code.
  • fmt
    • For python like str.format.
  • date
    • For date calculation.
  • libzmq
    • For networking.
  • zmqpp
    • For networking.

Build

Build all

git clone --recursive https://github.com/yukinarit/python-cookbook-in-modern-cpp.git
cd python-cookbook-in-modern-cpp
mkdir build
cmake ../src
cd build && make

Build a project

cd src/7/carrying_extra_state_with_callback_functions
mkdir build
cmake ..
cd build && make

Cookbook

Chapter Recipe Description Code
1 Determining the Most Frequently Occurring Items in a Sequence Find an item that has the most occurence in list python / C++
1 Calculating with Dictionaries Calculating max/min of item in dictionary python / C++
1 Filtering Sequence Elements Appliying various filterings to list python / C++
1 Finding Commonalities in Two Dictionaries Calculating intersect from two dictionary python / C++
1 Finding the Largest or Smallest N Items Finding the Largest or Smallest N Items from list python / C++
1 Implementing a Priority Queue Implementing a Priority Queue python / C++
1 Keeping the Last N Items Search a word in a text file and get the last n lines before the mached line python / C++
1 Mapping Keys to Multiple Values in a Dictionary Dict manipulation python / C++
1 Removing Duplicates from a Sequence while Maintaining Order Removing duplicates using range algorithm (Generator in Python) python / C++
1 Removing Duplicates from a Sequence while Maintaining Order WIP python / C++
1 Sorting a List of Dictionaries by a Common Key Sorting dict by key (Using rambda in C++, itemgetter in python) python / C++
1 Sorting Objects Without Native Comparison Support Sorting Objects Without specifiying a comparison function python / C++
2 Combining and Concatenating Strings Join and Buffer string python / C++
3 Determining Last Fridays Date Date calculation python / C++
4 Creating New Iteration Patterns with Generators Implement range(0, n, step) like function with generator python / C++
4 Iterating Over the Index-Value Pairs of a Sequence Implement python's enumerate function python / C++
4 Iterating in Reverse How to work with iterator python / C++
4 Iterating in Sorted Order Over Merged Sorted Iterables Merge and sort two collections python / C++
4 Iterating on Items in Separate Containers Iterate two collections python / C++
4 Delegating Iteration Iterate childlen python / C++
4 Defining Generator Functions with Extra State Implement enumerate like function with state python / C++
7 Carrying Extra State with Callback Functions Write callback in many ways python / C++
7 Writing Functions That Accept Any Number of Arguments Writing a function that accepts variable number arguments using Variadic template python / C++
7 Defining Functions with Default Arguments Pitfall of using mutable type as default argument python / C++
7 Making an N-Argument Callable Work As a Callable With Fewer Arguments An example1 using partial(bind in C++) python / C++
7 Making an N-Argument Callable Work As a Callable With Fewer Arguments An example2 using partial(bind in C++) python / C++
7 Making an N-Argument Callable Work As a Callable With Fewer Arguments An example3 using partial(bind in C++) python / C++
9 Applying Decorators to Class and Static Methods Trying to make decorator-ish macro using variadic template python / C++
11 Creating a TCP server Creating a TCP echo client python / C++
11 Creating a TCP server Creating a TCP echo server python / C++
11 Creating a TCP server Creating a TCP echo server using iostream like interface python / C++
11 Creating a TCP server Setting option by setsockopt python / C++
12 Communicating Between Threads An example using mutex and locks python / C++
12 Communicating Between Threads An example using condition variable python / C++
12 How to create thread pool Creating simple thread pool using lock and condition variable python / C++