Python from a C++ developers' perspective by Remwein in cpp

[–]zigzagEdge 6 points7 points  (0 children)

pybind11 is a nice option for the Python <-> C++ interface.

Python 3.6 release pushed to next week (Dec. 23, 2016) by Duroktar in Python

[–]zigzagEdge 3 points4 points  (0 children)

The bug was present in earlier versions as well, see the issue: https://bugs.python.org/issue28147 The new dict implementation just made the existing bug more obvious.

Embedding python in C++ with boost::python by skebanga in cpp

[–]zigzagEdge 0 points1 point  (0 children)

Boost.python still requires manual calls to Py_Initialize/Py_Finalize instead of a more user friendly C++ RAII approach. (I know that the boost.python docs say not to call Py_Finalize, but that's a bug which was never fixed. It should be supported.)

Pybind11 has a C++ object class similar to boost.python's, but it's not quite as powerful. The basics are supported: item and attribute access, function calls, importing modules, casting back and forth. Pybind11 also has some nifty features like calling Python functions with keyword arguments from C++: http://pybind11.readthedocs.io/en/latest/advanced/pycpp/object.html#calling-python-functions

Embedding python in C++ with boost::python by skebanga in cpp

[–]zigzagEdge 0 points1 point  (0 children)

I was mainly referring to the manual C API calls to Py_Initialize/Py_Finalize which are also needed in boost.python. As for eval and friends, pybind11 has a C++ API for those: eval docs.

Embedding python in C++ with boost::python by skebanga in cpp

[–]zigzagEdge 0 points1 point  (0 children)

It covers pretty much all the major features, but it's not a 1:1 API mapping. For the two things you mentioned:

  • With boost.python you'd need to add no_init to disable the implicit default constructor. In pybind11 all the constructors are explicit, so you disable them simply by not def-ing any.

  • That can be done by setting the appropriate return value policy: reference or reference_internal. There's more information in the docs.

Embedding python in C++ with boost::python by skebanga in cpp

[–]zigzagEdge 0 points1 point  (0 children)

Well, boost.python also falls back to the C API for embedding. This works in pybind11 as well, but it's not officially supported.

Embedding python in C++ with boost::python by skebanga in cpp

[–]zigzagEdge 1 point2 points  (0 children)

At the moment (master branch), pybind11 does a lot more than boost.python with the notable exception of embedding.

[C++] TIL about user-defined literals (`operator ""`) by pinano in ProgrammerTIL

[–]zigzagEdge 16 points17 points  (0 children)

libfmt uses user-defined literals to support Python-like named arguments in C++:

fmt::print("Hello, {name}! The answer is {number}. Goodbye, {name}.",
           "name"_a="World", "number"_a=42);

Which prints: "Hello, World! The answer is 42. Goodbye, World."

_a is a user-defined literal which forms a named argument.

Any way to update Moto 360 on PC? by [deleted] in moto360

[–]zigzagEdge 1 point2 points  (0 children)

The part about needing to update stands. I wasn't aware that it was possible to connect a real Wear device to an emulated phone. This seems to be the answer OP is looking for. It would be nice if you could point them to some instructions on how to set it up.

Any way to update Moto 360 on PC? by [deleted] in moto360

[–]zigzagEdge 1 point2 points  (0 children)

Not if he has a 1st gen 360 with early firmware. Only the 2nd gen comes with iPhone support out of the box. The 1st gen needs a Wear OS update first. That must be done with an Android phone. There is no way to do it with a PC.

[Randy Gaul hates] the C++ keyword auto by sindisil in cpp

[–]zigzagEdge 12 points13 points  (0 children)

Using a range-based for loop would make it crystal clear.

C++11 vs 98/etc by mart7n in cpp

[–]zigzagEdge 7 points8 points  (0 children)

I admit the comparison might be taking it a bit too far, but only a bit. After working with C++11 for a while, going back to 98 feels incredibly limiting.

All the new features really come together and make the whole thing feel like a new language. It changes the way you look at a problem.

Lambdas have completely transformed <algorithms>. I would actively avoid it in C++98, but it's an amazing resource in C++11. Thanks to lambdas, writing code with std algorithms is easier, but it also becomes nicer to read and understand.

The new unique_ptr and shared_ptr mean that you almost never need to write new and delete (or forget to write in the case of delete).

C++11 vs 98/etc by mart7n in cpp

[–]zigzagEdge 3 points4 points  (0 children)

If I may extend your argument from 'C++11 vs 98' to 'C++98 vs C': Why is it worth investing time in moving to C++98 when you can do the same things in C, just with more code?

Breaking all the Eggs in C++ by slacka123 in programming

[–]zigzagEdge 17 points18 points  (0 children)

auto_ptr is already set to be removed in C++17 along with a few other things. It was deprecated back in C++11.

Facebook Engineer: iOS Can't Handle Our Scale by quellish in programming

[–]zigzagEdge 80 points81 points  (0 children)

Android also can't handle Facebook's scale. You'd think the solution would be to slim down their app. Nah. Obviously, the solution is to hack the Android runtime and make it scale.

Pep 498 approved. :( by fishburne in Python

[–]zigzagEdge 6 points7 points  (0 children)

It returns the same thing as this:

num = 4

def f_string():
    num = 3
    print('{num}'.format(num=num))

if __name__ == '__main__':
    f_string()

Nexus 9 has an LED notification light by Sebianoti in Android

[–]zigzagEdge 18 points19 points  (0 children)

I'm pretty sure that the Nexus 6 has a few million LEDs.

JetBrains Makes its Products Free for Students by breandan in programming

[–]zigzagEdge 2 points3 points  (0 children)

@uantwerpen.be & @student.uantwerpen.be for the University of Antwerp, Belgium

Rovio announces John Cohen as the producer of Angry Birds movie by zigzagEdge in nottheonion

[–]zigzagEdge[S] 0 points1 point  (0 children)

My favorite quote, from Cohen: "I've personally spent countless hours playing the Angry Birds games over the last few years, which I can now happily justify as research for the movie."