Unleash the power of C++ in Python
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Subtitle |
| |
Title of Series | ||
Number of Parts | 118 | |
Author | ||
License | CC Attribution - NonCommercial - ShareAlike 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this | |
Identifiers | 10.5446/44756 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
| |
Keywords |
EuroPython 2019115 / 118
2
7
8
15
20
30
33
36
39
40
45
49
51
55
57
58
63
64
66
68
69
71
74
77
78
80
82
96
98
105
107
108
110
113
115
00:00
GoogolPoint cloudKeyboard shortcutProcess (computing)Moment (mathematics)Software engineeringOffice suiteTrailReal numberComputer animationJSONUML
00:39
Slide ruleSource codeProgram slicingProjective planeSlide ruleRepository (publishing)Source codeLink (knot theory)Uniform boundedness principleGodLecture/ConferenceMeeting/InterviewComputer animation
01:11
Programming paradigmMultiplicationCompilerRead-only memoryData managementSoftware maintenanceProgrammschleifeLambda calculusFunction (mathematics)ClefStrutObject (grammar)Disk read-and-write headModule (mathematics)CodeFormal languageStandard deviationType theoryMultiplication signRevision controlRange (statistics)Vector spaceHand fanVideo game consoleCodeSemiconductor memoryProjective planeFunctional (mathematics)Module (mathematics)Different (Kate Ryan album)CASE <Informatik>Similarity (geometry)Extreme programmingLine (geometry)AuthorizationGoodness of fitTemplate (C++)IterationLambda calculusPairwise comparisonProgrammschleifeNeuroinformatikDynamical systemCompilerRight angleComputer scienceGraph coloringMetaprogrammierungCase moddingElement (mathematics)Memory managementSoftware frameworkSlide ruleCivil engineeringProcess (computing)1 (number)
05:37
Normal (geometry)Ring (mathematics)Functional (mathematics)Computer fileString (computer science)CodeDeclarative programmingMessage passingContext awarenessSummierbarkeit
06:15
Interior (topology)File Transfer ProtocolDisk read-and-write headModule (mathematics)Module (mathematics)Functional (mathematics)Directory serviceMultiplication signData structureRight angleCASE <Informatik>Endliche ModelltheorieComputer animation
06:50
Computing platformSoftware frameworkSocial classGroup actionDatabaseSoftware frameworkGraphical user interfaceFunctional (mathematics)User interfaceDifferent (Kate Ryan album)Computer animation
07:30
Computing platformSoftware frameworkComputer configurationPoint (geometry)Projective planeSet (mathematics)Web 2.0Keyboard shortcutMoment (mathematics)Right angleComputer configurationFormal languageLevel (video gaming)Software frameworkOpen setWritingRaw image formatComputer animation
08:26
Simplex algorithmComputer virusLetterpress printingFunctional (mathematics)Computer fileMoment (mathematics)Interface (computing)Message passingImplementation
09:15
Computer virusComputer configurationEmailModule (mathematics)NamespaceMoment (mathematics)OvalProjective planeInformationPlastikkarteParameter (computer programming)Process (computing)Web pageWordSoftware frameworkCodePhysical systemSoftware developerInterface (computing)Source codeSlide ruleBitType theoryCasting (performing arts)Wrapper (data mining)CASE <Informatik>Multiplication signComputer fileGraph (mathematics)Set (mathematics)Keyboard shortcutDependent and independent variablesFunctional (mathematics)Computer configurationProper mapLibrary (computing)Object (grammar)MereologyRight angleExistential quantificationWebsiteGraph (mathematics)Disk read-and-write headData miningComputer animation
12:43
Computer virusKeyboard shortcutLibrary (computing)Standard deviationPhysical systemEmailImplementationComplex (psychology)String (computer science)Type theoryBitFunctional (mathematics)
13:30
Modulo (jargon)Module (mathematics)CountingObject (grammar)Wrapper (data mining)Order of magnitudeWrapper (data mining)CodeModule (mathematics)Computer configurationLibrary (computing)Functional (mathematics)Source codeJSON
14:06
Computer configurationProjective planeSession Initiation ProtocolComputer configurationSet (mathematics)Keyboard shortcutCode1 (number)Computer animation
14:42
Normal (geometry)Computer virusInclusion mapMessage passingGastropod shellMoment (mathematics)Multiplication signCASE <Informatik>Computer configurationComputer fileGoodness of fitFunctional (mathematics)Macro (computer science)Computer animation
15:26
Type theoryFlagContext awarenessField (computer science)CodePairwise comparisonComputer animation
15:52
String (computer science)Computer virusCompilerLibrary (computing)Functional (mathematics)Raw image formatString (computer science)Row (database)CASE <Informatik>JSON
16:15
Computer virusString (computer science)CompilerSource codeComputer configurationCodeWritingReading (process)Computer configurationDeclarative programmingString (computer science)Similarity (geometry)Session Initiation ProtocolJSONComputer animation
17:01
Computer configurationModule (mathematics)Computer virusKeyboard shortcutComputer fileSession Initiation ProtocolDifferent (Kate Ryan album)Module (mathematics)Computer animationSource code
17:25
Computer virusModule (mathematics)Normal (geometry)Computer configurationCodeElectronic signatureFunctional (mathematics)Computer configurationRight angleData conversionSoftware testingData storage deviceModule (mathematics)BitComputer fileLibrary (computing)CASE <Informatik>Line (geometry)Source codeComputer animation
18:37
Module (mathematics)CodeRecursionDependent and independent variablesFile systemComputer fileCASE <Informatik>Standard deviationLocal ringBus (computing)System callRight angleRecursionDirectory serviceElectronic mailing listModule (mathematics)
20:13
Object (grammar)RecursionDirectory serviceString (computer science)Manufacturing execution systemHill differential equationRemote Access ServiceMenu (computing)BenchmarkDifferent (Kate Ryan album)CASE <Informatik>LeakDirectory service2 (number)ResultantScripting languageParallel computingBinary fileFile systemGastropod shellBitCore dumpSemiconductor memoryIterationFunctional (mathematics)Computer fileImplementationIntegrated development environmentCodeMultiplication signParameter (computer programming)Electronic mailing listRecursionComputer configurationPhysical lawModule (mathematics)MereologyStapeldateiComputer animation
23:01
Module (mathematics)CodeInterface (computing)SynchronizationType theoryComputer fileGoodness of fitInformationWrapper (data mining)Projective planeSlide ruleRevision controlDynamical systemDifferent (Kate Ryan album)Object (grammar)Session Initiation ProtocolProcess (computing)Computer animation
23:59
Local ringGroup actionMoment (mathematics)Local GroupMusical ensembleMultiplication signComputer animation
24:37
Operator (mathematics)Different (Kate Ryan album)Function (mathematics)Electronic mailing listDefault (computer science)Session Initiation ProtocolData dictionarySocial classEquivalence relationType theoryObject (grammar)Arc (geometry)Set (mathematics)Electronic signatureFunctional (mathematics)Parameter (computer programming)CodeSquare numberTable (information)INTEGRALProjective planeMeasurementCASE <Informatik>Poisson-KlammerComputer configurationComputer filePositional notationKeyboard shortcutLengthCasting (performing arts)Overhead (computing)Vector spaceLocal area networkLecture/Conference
28:31
Group actionLocal ringEmailFunctional (mathematics)Social classElectronic signatureGUI widgetType theoryPointer (computer programming)Queue (abstract data type)Computer animation
Transcript: English(auto-generated)
00:03
Hello, everyone. This is one room more than I was expecting for, because I know that there is also amazing talks that I would like to go to at this moment. So if you want, we can all go to the other talks, or we can stay here for some fun with C++, of course. And I know this is the last talk from all the tracks,
00:22
so bear with me. There will be no weird things here, and we will not be trying to understand obfuscated C++ or something else. It's a really light talk with advanced topics. So let's go for it. So as you heard, my name is Cristian. Currently, I'm working as a software engineer in the Qt company, which is one of the companies that
00:41
support the Qt project. Maybe you heard about it. Later, I will have one slide to explain the motivation behind this talk and why I'm talking about C++ and Python. So first of all, don't worry about the examples or the slides or whatever. Just go to that GitHub repository. There is a link to the slides, and you're going to get all the source code.
01:00
Oh my god, I feel like a star, everyone taking pictures. Stop it. As you can check it out, at the end of the talk, also is my GitHub username, so you can check it out. It's called unleash-cpp. Okay, so first of all, the Qt project in general is a C++ framework, huge framework, and with starting to do some Python stuff,
01:21
you need to have the mandatory comparison between two languages. First of all, we know that both languages are general purpose. Then also you have multi-paradigm. You can do many things with them. And then we start to notice some difference that I'm pretty sure that most of you are aware of. Dynamically type, statically type, compile, interpret,
01:42
and then memory management, and about also code reliability. So I know this is kind of a, if we have, just raise your hand, who is currently writing C or C++ code? Okay, good. So I feel your pain too. So I know that sometimes C++ could be complicated, but I just want to show you that it's not,
02:02
and you can even make things in Python better. So first of all, everyone knows that Python is beautiful. I remember the first time that I typed that on a console when I was studying computer science, and it was, whoa, everything works. But if you think about it, I mean, C++ is not so different, right? I mean, you can write something that maybe you need to run an external compiler
02:22
or something, but you achieve the same thing, right? So, okay, after all, C++ is simple. It's not. Because then you have things like meta-programming, and you start, you know, templates over templates, and this is one of the reasons that people get scared of C++. But C++ is not so ugly, and this is some extreme cases of people
02:40
with a lot of time, a lot of effort, and try to do these complicated things, like compile time if. But let's go about one of the goodies, a couple of goodies, that C++ and the latest standards being 11 on. I mean, if you're familiar with C or C++, now there is this amazing auto-type that kind of detects the variable that you have,
03:01
which is kind of a similar, like a more dynamic language, but not. You can even use some functions to get the declarative time of a different variable to declare another one and stuff. And then, again, we have the four loops that, with time, it has been improved. I mean, this is kind of the more dumb old version
03:21
that we have in C++ to kind of go in a vector. I know that you can do also with an iterator too, but it's kind of like going element by element, but it's too complicated, so then you can do more fancy things like this, and if you remember the author one, then you can kind of go at it, which is not so complicated to understand. Also, if you're a fan of Python lambdas,
03:41
you can also do it in C++ with the latest standards and so on and so forth, and you can have this for each, handling a nice lambda there to just summing up some values. But the most interesting things about C++ are coming, in my opinion, in C++20, which is, I don't know, have this relationship with love and hate with C++20.
04:01
There are some things that are really nice and some things that I have no idea why people is doing it, but one of the things that I like is this one. So you have this amount, sorry, this type of ranges that you can use now, and if you see the four, the kind of like the type of the four there, it's kind of similar that you can have there. After all, I mean, it's not so crazy different, right?
04:24
The same with a more example, I mean, I know that the smart way maybe is the first line that is commented out, but you can write the function maybe like the second line that you see there, which is also quite similar to what you can achieve in C++20. So after all, I mean, it's just adding some semicolon centiad, right?
04:42
The idea is that now it's not about which language is best, but how to make both languages to improve each other and try to collaborate in a more efficient way. So I want to propose now a new language that is called, no, no, it's not, but I'll just talk it to extending Python with C++. And for this, we will go through a couple of examples,
05:02
really simple ones. Who here didn't know before the conference that Python was written in C? We had some? Okay, we had some people, okay. So this is something that also was kind of shocking to me because I thought that it was some black magic assembly stuff, but it was written in C. So if you learn some C, you could understand it. And then you can understand other things
05:22
like this joke, for example. I know that is really bad, but it's the only joke that I have on the slides. So I'm really sorry, but I needed to do it. So let's take a look at how we can create an amazing module based in pure C Python. And okay, let's go for it. So the first thing that you need to know
05:40
is that you just need a C file. And we will go through these examples with the most simple thing that I would think, that it was a hello world function that just returns the char star or string or whatever. So I hope that everyone can read. If you don't know C or C++, it's kind of that you get the idea. It's kind of a function declaration
06:01
that returns some message, which is hello, you're a Python 2019, okay? So for building a C++, I will just sum out, don't be afraid, just to show you. So that's all the code that we required to create a new Python module written in C Python, which one function that is just printing hello world.
06:21
It's not so scary, right? I mean, I need to confess, the first time that I started to play around with this, I was just copying all this weird structure that you have around and all this, why does that, null, null, zero, and other things. You just copy some stuff and it works. So if you are brave enough after this talk, just go to the C Python directory and play with it. And maybe you can write
06:41
other sophisticated models with it. So this is a simple case, right? And this is just one example, one simple function and we have this. So what's the motivation behind this Qt thing? So Qt is just a C++ framework that is huge and one of the main functionalities
07:00
was to offer the way of developing graphical user interfaces for people. And also, Qt implements many of the things that we have for free in Python in C++, which is a lot of instructions for different classes to interact with more for databases or maybe doing command line or scripting alike in C++.
07:22
And even other advanced things, a different way of creating user interfaces, actions, notification, threats, all these things. So they are providing a lot of goodies to the C++ world and at some point, the project was, but you know what, we should, I mean, this thing need to be maybe available in other languages. So people started to wonder about Python.
07:41
So maybe you are aware, there is already a set of binding which is really old, it's called PyQt and this was developed by a different company, some people doing a lot of work there and this was fantastic. And in the good project, they wanted to kind of have an official adoption of these things. So they decided maybe we can create a new set of bindings
08:00
and just put it there and see, it's an open market so people can decide which to choose. At the moment, they are at the same level. One is really old and there's a lot of examples and tutorials. But the Qt project at that point had a couple of options to do this with this huge C++ framework. So they could write raw C Python, they could wrote SWIG,
08:22
I mean, maybe you heard about SWIG or they could use Boost Python. So if you take a look at the SWIG implementation, so with SWIG, just for you to believe me, we have here our difficult function to understand and the only things that we need to do for SWIG
08:41
is just to create an interface. So this interface is in an i file that also nothing really scary or something at the moment. So we have a couple of instructions to build it. I mean, we run SWIG and then we compile some stuff and then we can just use a normal, simple, import the module and execute it.
09:03
And then we have the message, nothing too fancy. With Boost Python, it's kind of a similar story. We go there again, we have this simple CPP file with our function there and then we just need to define Boost Python module, the name, the namespace and then we define the function.
09:23
Nothing too scary at the moment, right? So this was looking at a really nice solution, right? I mean, we were achieving the same thing but the problem lied that many things that we do in C++ need to be specially treated inside Python. For example, ownership of objects. If you are wrapping an interface that is in C++,
09:43
who owns the objects? Some cases will be Python, some cases will be C++. So you need to deal with all these things. Okay, so the option that at that time the developer had was, okay, this is one of the generator and we can maybe modify the wrapper generated code. So let's take a look of the code that SWIG generates.
10:03
So just for you to have an idea, so this is kind of the code that generates and I will start to go down. We're in 2%, 3%. Okay, we'll just page down, four, five, seven, two. So I understand it. It's a little bit too much with this small function, right?
10:21
So, okay, that's over. And there is kind of a motivation to say, okay, I know that they need to set up many things to get for granted and to automate many process and it's a really smart solution but if you want to modify this file, it will be unbearable. I mean, you cannot do it. So there was a lot of motivation behind this. C Python and, sorry, and SWIG and Boost Python.
10:44
I don't have the source code from the Boost Python here but the shared library is roughly the same size so you can imagine that there are a lot of magic there. So what do they say? Okay, they started the development of this new tool based in Boost at the moment and they said, hey, no, it's too heavy, let's write our own thing.
11:00
Okay, everything was released properly. Then there was the project that continued the development and the good news was that last year officially was released this new set of bindings of Qt in Python and then their name of a new project was called Qt for Python. So maybe you heard about this or PySight tool. It was this, all this story behind. But, okay, this is just a story
11:21
but what was the important part, at least in my opinion? How do we do it? So this tool that you see here in the center called Jevoken2 is kind of like the response for writing our own code generator tool to expose all this huge C++ framework to Python. So there is a module inside
11:40
that it kind of extracts all the API information from Qt based in Clang, of course, if you want to do smart things in C++ you need to use Clang. Then we have a support type system which is nothing else than an XML file. Then you get, wait, something is being weird, an XML file where you can define all these things that I told you about ownership or, for example, what do we do if a function
12:01
has a void star argument in Python? We need to have a special or type or treatment or do some casting or something around. So this tool graphs this type system, the information from the framework and generates some wrapper, the one that you saw from SWEET but, of course, more reduced and it makes more sense and it's more clean, in my opinion.
12:21
And then with this we can just compile it and have the same Python module that we have. So this tool is called Jevoken, the documentation is there and I don't know what is happening, I'm not doing anything and the slides are coming. Okay, so the Japanese Genji doesn't mean anything. If we have some Japanese speaker there here,
12:40
it's just three words that make no sense but let's take a look of the Jevoken thing. Okay, so again, we will go first for you to believe me that we have here the implementation and we are cheating a little bit because, of course, we are working with strings from the standard library. Then we define a complex header for this,
13:03
which is just that. And for this type system that I just told you, it's nothing else than this. So we've had HTML, we said this will be a package called simple, it will have a primitive type, there's a string from standard library and a hello function. After all the compiling and stuff,
13:23
we will get something like this. And let's go to build. And it's inside simple and here you have the module wrapper. I will zoom out just for you to show that I'm not lying.
13:41
It's long but it's not so long as the other one. So here you have it, I don't expect you to read the code, I just want to show you the magnitude of the code. So at least this is being code automatically generated, calling the C++ function and exposing everything with C Python to be able to use it from Python. So it's way shorter than the option that we had and of course this translates into having
14:03
more lightweight shared libraries and you can achieve the same things. So there are other nice options out there and for this I kind of tend to recommend people to take a look of all the solutions that you have out there because it's unfair to say, yeah, this is the best solution, no, it's not.
14:21
I mean there are many things that you can complement to each other. I don't know if you have the chance or maybe know one of these ones. The last one, for example, is the one that the other set of binding called PyQt uses, which is called SIP. PyBind 11 also is a really nice project that appeared I think a couple of years ago, even I think two EuroPythons ago,
14:40
there was also a talk about PyBind 11. So let's take a look of like how do you achieve the same things with the other options. I think that I am good with the time at the moment. So this is the case of PyBind 11. So let's open again the file. If you see the motivation here is clearly from Boost Python.
15:01
I mean it's again a kind of a macro that kind of defines a module, then you have the definition of the function, some documentation and so on and so forth, and then you can do the same thing. I mean after you compile it and everything, you have your simple main that you can achieve the same. So it's kind of like same idea as Boost Python,
15:20
but they are doing way more things and there is a lot of nice support there that I encourage you to check it out. CFFI, well this is again not really fair comparison because CFFI, we had some talks already that we explained about this thing. It's not kind of like generating code, but it's just kind of loading something.
15:42
So we can have, this is the one here. This is the code that is being generated, yes. So we go to the simple build and then you have the inline raw string that contains the function that we want to expose
16:00
and then we just compile this thing in some shared library that we can easily load from Python. So if you check here for example, the main is the same thing that we were seeing in the other examples, just calling this nice function. In this case, we are casting two strings and so on and so forth, but it's kind of the same idea. But again, I mean it's not like you can write inline code
16:21
or kind of read lots of C++ code to kind of expose it in this way. The other option that I had there, oh, of course. CFFI is kind of focused on C, well I mean they support C89 and I don't remember which one others are there. But for playing with C++, you have a similar idea which is CPPYY.
16:43
Kind of fun, right, CPP, okay. And then it's kind of the same idea. So you declare everything like in a string and then you have this declaration that you can use this from the GBL. Again, same idea and nothing too scary. And the last one is kind of similar. It was a zip that I show you,
17:02
the one that is using the PyQt bindings. I will just show you, this is just there. So yeah, here you have the simple, again, same idea, but the only difference that they require to define a zip file,
17:21
and it's nothing like else at this. I mean it's also quite simple. I mean you just need to define the module and then you have some include and then the signature of the function. So there are many options out there to achieve the same thing, right? But what's the idea of doing this, right? I have been having some conversations with people sometimes
17:41
that they say, ah yeah, but I mean I use Python for everything. I mean you don't need C++. And I say, okay, what do you use? No, I do everything with Numpy because it's amazing and it's fast and it's Python, you know? And then it's like, yeah, you know, it's written in C. No, it's not. So okay, there's even some people that is not aware that many of the popular libraries out there are using C++ or C.
18:00
So in this case, we have a case of Numpy. I just downloaded the source code. The first line is all the Python files that they have that is not test, and then you have the C files there, which is 96, which is still a lot of things that they are doing. And if you want to maybe refer to a more modern module, the case of PyTorch is a little bit more extreme.
18:21
Then if you look there, we have, no, this is, no, this was, this is wrong. So here, we have 547 C++ files inside the PyTorch because of course it's based in Torch and Torch is C++, so everything is C++ inside. So it's kind of a nice motivation of using all these tools
18:41
to start to write things to improve the Python. We are all here, and if we know C or C++, we kind of have some responsibility in our hands to improve things. And one of the examples that, just out of curiosity, and please don't blame me about the things that I will show you, is that simple case. I was helping someone that was listing some files in Python
19:02
and getting all different absolute paths, and what do you use there? Globe, right, when you use globe. Or if you are more like up-to-date person, you use the bath leaf, and then also you have the globe access there. So for this, you know, the deal,
19:20
I mean, writing a globe is, things are kind of simple. This is a hard-coded thing just to play with the recursion thing, but you know, import glove, and then you need to double stars there and specify if it's recursive, no. The same way which path leaf is kind of the same idea. Right?
19:42
And then I thought, I mean, let's look at the implementation and see if we can kind of do something smarter in C++. So the first thing that came to my mind that in C++ 17, maybe, you know, there is a new adoption in the C++ standard, which is the module called file system. This is based in the boost file system. So I thought, okay,
20:00
I will just copy paste the hello world example there, and I will put the file system call to list directories. So again, same idea. I will just replace all the simple and hello, and the only difference is this. If there is any C Python core developer in the audience,
20:21
please forgive my C Python, but this is just to show how simple we can achieve things. Of course, this is unsaved. There is memory leaks there because when you append, that increase the ref counts, and I am not taking care of anything, but just taking one argument, which is the recursive, to see true or false, and create an empty list,
20:40
and then just doing some dumb appends. So the magic here from the C++ side is that I am using the file system module, I am using C++ 17, and there is luckily some directory iterator that you can kind of do recursively or not, and that's it. I mean, if you don't know C Python, this is just a function that will take here some arguments,
21:01
we create an empty list, and then if it's recursive enough, we are appending, well, you know how append works, some stuff, and then we are returning this list. Nothing else. So I thought, okay, let's see how this thing was working, and then I wrote a really, really simple bash script, because, yeah, I was growing up with bash, and I thought, I will just have this scenario
21:22
when I have 1,000 directories with 1,000 files inside of each empty files, and I'm going to list them. So I just create a shell script to measure this, as you can see here, the glove, the non-recursive option, which is just listing the directories inside this fake environment, it's 0.05.
21:41
I was not expecting glove to take so long, but I think that it should be something around 20-something seconds. I mean, in the meantime, I can tell you that I was afraid that maybe I was using user bin time, and maybe it's not the proper way of doing it. So, okay, there you have it. Recursive, 33 seconds. We were talking about all these files. Then I tried a badlive.
22:01
Again, it was a little bit more, it's lower than the glove file. Then the other case is the recursive way. It will be roughly, I guess, at the same, if I'm not wrong. I should have had this prepared. Okay, there you have it, 20 seconds. And then the fast glove implementation that I have there,
22:21
it's less than a second. I mean, I know I am not taking care of cache, or, you know, the, I don't know, releasing the GL to use parallel computer or something fancy, just the simplest thing that you can think. And then you have it. I mean, it's, and then I thought, maybe it's the same thing. I am doing it wrong. So let's do the same performance in Python, which, you know, the time module or something.
22:41
And after all the twice, it was more or less the same result. And it's not like I want to say, yeah, this should be the new glove, but this is how easy you can improve things there. And maybe you are thinking in the next numpy, the next pandas, the next PyTorch or something like that. Well, I will not wait for the results there, but it's roughly the same, believe me.
23:02
So yeah, this is a summary. It's okay if you cannot read everything because you can check the slides afterwards about the versions that you can use, the licenses, the compatibility with Python. Here, I just want to highlight Chibokan, the thing that I am working with, and also SIP because there is something that is called Stable ABI. Maybe you heard about it. Yes, yes, Stable ABI, good.
23:22
So this is just for developers to release wheels that are compatible with Python 3.5 onwards. I don't need to have different wheels with different Python versions. So this is really tricky. It's just the way that you create objects are a more dynamic way, but it's really hard and it's implemented in those two options. So there you can have information from the PySAT project.
23:42
You can find me here also. You can check my social networks and all the information and you can just type make. I add some make files there just for you to know the process of building all these wrappers so you can start playing around today about it. And just as a PSA that it's always good
24:01
to support your local groups. So if you, at any moment you come to Berlin, I mean we have I think one of the most amazing Python communities out there. We have PyLadies, Python users Berlin, PyBerlin and PyData Berlin. So that's it, thank you very much.
24:23
All right, thank you very much. We have time for some questions. We have actually five minutes, so a couple of questions for sure. And if you don't like your voice on a microphone, maybe you can find me outside. I will be here until Friday or we can hang after a couple of beer or we can discuss the truth behind C++. So if you have questions, yes.
24:45
Did you ever look into performance overhead differences between those options? No, I haven't and I wanted to, but then I thought that's not a half an hour talk. So I was really considering for the meetups or conference to kind of do this kind of thing
25:01
because I want to measure code length performance which is also critical. I mean I have noticed some stuff a bit different between the SIP and the Shiboken for example, that there was an issue that Shiboken was way slower because we were using lists in C++ and SIP was using vectors. And then we have for example, in some tables or cases like this,
25:21
they were kind of different. But yeah, it's a good question and I will try to maybe next year, I will have one performance. Thank you. Any more questions? Oh, excellent. You can shout if you want to.
25:49
Yes, lately there was something that fixed that because I wanted to implement breaking the Qt API, having for example for Qt settings to have explicit cast in types
26:01
and I needed to use the name arguments. So now it's implemented and it's out there. So you can do it. And now there's a new notation which is the at. So you use the at between the name that you want to use and then you have nine arguments and you can parse it like a normal dictionary for the arcs and the... So yeah, you can ask me later if you want.
26:21
I can show you how to do it. Okay, any more questions? Do you hear me? Yeah. Does the Shabokin uses some... Does it have some CMake integration?
26:43
So yeah. It's CMake. It's CMake and you can make a C++ project and use CMake integration in your project. Okay. Yes. And does it... For example, you want to override LAN or some other Python features.
27:03
Can you override it in XML file for bindings? Can you name one? I mean, the only override that comes to my mind is that, for example, you can kind of like remove functions and replace it with a whole new Python equivalent. Okay. So signature-wise or functions. We can remove arguments sometimes.
27:20
Yeah, but items like square brackets, overrides. Operators. Operators, yeah. Yes, I mean, we have some special treatment for a few operators. I don't know how much you can modify this thing, but at least I know that you can manually modify, for example, the lower-lower operator in C++ and in Python to do different things.
27:40
So you kind of like override the Python's default stuff. Yeah, so for example, I have C++ method size and the other one is operator for accessing it and I want in Python to just use square brackets for operating. As long as you define this operator inside the type
28:01
of the variable, it will be possible because underneath, it will call this specific rewriting that you have. Okay, thank you. You're welcome. Any other question? Any other question? I will ask you a question.
28:21
Oh, okay. So how is it to wrap a C++ class and modify it? Yeah, it's kind of the same thing that you saw there. You need to just, the class will be an object, so you declare a new object and then inside you have any function that you want to modify. If you don't want to modify it, you just close the tag
28:41
and that automatically go to your header, see the class, take all the signature and expose everything, if everything is normal in the sense of like there is no void star or weird, you know, kind of like the pointers working around, so yeah. And can you then subclass that class from within Python as you would be knowing?
29:01
Yes, totally, because you are exposing some new type in Python. So for example, the simple things that you can have in Qt is a Qt widget and then this is C++, you're exposed to Python and the recommended way of doing it is to use this as a meta class for your new class in Python that is, I don't know, called my widget or something like that. So you can do it.
29:21
Wow, very nice.