Call a C API from Python becomes more enjoyable with CFFI

Video thumbnail (Frame 0) Video thumbnail (Frame 673) Video thumbnail (Frame 1317) Video thumbnail (Frame 10436) Video thumbnail (Frame 11109) Video thumbnail (Frame 14743) Video thumbnail (Frame 16660) Video thumbnail (Frame 17290) Video thumbnail (Frame 18394) Video thumbnail (Frame 24924) Video thumbnail (Frame 29800) Video thumbnail (Frame 38601) Video thumbnail (Frame 40013) Video thumbnail (Frame 42880) Video thumbnail (Frame 44500)
Video in TIB AV-Portal: Call a C API from Python becomes more enjoyable with CFFI

Formal Metadata

Call a C API from Python becomes more enjoyable with CFFI
Title of Series
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 license.
Release Date

Content Metadata

Subject Area
Call a C API from Python becomes more enjoyable with CFFI [EuroPython 2017 - Talk - 2017-07-12 - Anfiteatro 2] [Rimini, Italy] Python is slow ! Python can’t access bare metal! You often hear theses assumptions? Theses limitations can be surpassed by Python extensions written in C. However, according to my personal experience, doing this by leveraging C may yield to several issues (e.g., memory management). C Foreign Function Interface for Python (a.k.a., CFFI) allows you to easily write Python extensions. One of the main aims of CFFI is to to wrap C libraries. Along the same lines, it may also be used for performance enhancement. By this call, I am firstly presenting CFFI and it’s two modes of utilization: API level and ABI level. Then I will share my own experience about wrapping shaderc library ( in six hours pyshaderc ( Next we are going to the next level, let’s wrap all the Vulkan API! Vulkan is the new 3D API and is not a piece of cake. To see the real advantage of CFFI, a side by side comparison between two Python modules is going to be presented: CVulkan is a Vulkan wrapper written fully in C, it’s a classic C extension for Python vulkan is its CFFI counterpart without any C written, only Python I have developed two versions of Vulkan wrapper (one in a pure C, and the second by leveraging CFFI) and I can assure you that CFFI is a a way better! Let’s code
Intel System call Software Coma Berenices Extension (kinesiology)
Complex (psychology) Application software System call Run time (program lifecycle phase) Confidence interval Multiplication sign View (database) Open set Parameter (computer programming) Interface (computing) Mereology Computer programming Neuroinformatik Type theory Bus (computing) Arrow of time Endliche Modelltheorie Extension (kinesiology) Physical system Social class Touchscreen Software developer Structural load Interface (computing) Hand fan Order (biology) Website Right angle Ranking Quicksort Reverse engineering Directed graph Point (geometry) Functional (mathematics) Maxima and minima Machine vision Power (physics) Revision control Operator (mathematics) Task (computing) Module (mathematics) Dependent and independent variables Cellular automaton Variance Binary file Computer programming Field extension Personal digital assistant Optics Speech synthesis Iteration Game theory Mathematical optimization Window
Information Interpreter (computing) Continued fraction
Intelligent Network Area Presentation of a group MUD Line (geometry) Multiplication sign Demo (music) Combinational logic Sound effect Line (geometry) Event horizon Computer programming Hand fan Subset Spherical cap Encryption Endliche Modelltheorie Extension (kinesiology) Absolute value Data compression Amenable group Physical system
Functional (mathematics) Different (Kate Ryan album) Line (geometry) System administrator Web page File format Letterpress printing Parameter (computer programming) Affine space Statistics
Demo (music) Different (Kate Ryan album) Line (geometry) Multiplication sign Videoconferencing Sampling (statistics) Set (mathematics) Endliche Modelltheorie Extension (kinesiology) Fast Fourier transform
Logical constant Email Statistics Functional (mathematics) Module (mathematics) Wrapper (data mining) Computer file Line (geometry) Multiplication sign Decision theory Source code Data dictionary Event horizon Computer programming Medical imaging Goodness of fit Field extension Encryption Bus (computing) Data structure Traffic reporting Simulation Electric generator Gender Computer file Sound effect Physicalism Maxima and minima Ultraviolet photoelectron spectroscopy Line (geometry) Statistics Template (C++) Process (computing) Personal digital assistant output Right angle Quicksort
Logical constant Complex (psychology) Functional (mathematics) Freeware Computer file Civil engineering Frustration Parameter (computer programming) Latent heat Field extension Semiconductor memory Different (Kate Ryan album) Object (grammar) Modul <Datentyp> Data structure Extension (kinesiology) Error message Social class Logical constant Touchscreen Electric generator Computer file Interior (topology) Sound effect Ultraviolet photoelectron spectroscopy Price index Template (C++) Planar graph Connected space Field extension Uniform resource locator Arithmetic mean Film editing Intrusion detection system Figurate number Object (grammar)
Group action State of matter Multiplication sign Direction (geometry) Demo (music) Execution unit Combinational logic Set (mathematics) Bell and Howell Mereology Computer programming Neuroinformatik Formal language Web 2.0 Semiconductor memory Hypermedia Forest Encryption Arrow of time Endliche Modelltheorie Extension (kinesiology) Position operator Touchscreen File format Building Sound effect Electronic signature Arithmetic mean Right angle Annihilator (ring theory) Inverter (logic gate) Geometry Point (geometry) Web page Functional (mathematics) Wrapper (data mining) Disintegration Streaming media Wave packet Latent heat Natural number Gender Cellular automaton Neighbourhood (graph theory) Content (media) Compiler Personal digital assistant Game theory Object (grammar) Library (computing)
Film editing Process (computing) Linear regression Demo (music) Chain Physics Correlation and dependence Game theory
String (computer science) Weight Demo (music) Sound effect Coma Berenices Parameter (computer programming) Logic synthesis Condition number
Point (geometry) Order (biology) Speicherbereinigung Interface (computing) Coma Berenices Analytic continuation Theory Library (computing)
Predictability State observer Functional (mathematics) Image resolution Core dump Speicherbereinigung Energy level Right angle Library (computing)
welcome everyone in difficult to pass after such a question that this morning that by its objectives that atic but technically from so so if I give this talk
today is because they truly believe in 2 4 5 2 improvement ability and robustness of Python extension I want to share with you my knowledge and my experiments
in order to convince you to give a try to see if it's if if I'm next time you need to write a bite an extension if you're exist among the canine that's coming natural said that's if I would argue by 10 to the power of 1 step further I totally agree with him and his talk with full rank this vision so were
my I'm just a somebody that when I write a white repressive through every day and I'm a fan of open cells because system and you can find a big parts of my own contribution and more well I what Katrina grow it's a French companies that promotes freeze of and says this company which encourage me to give this talk to them the if you need to vote for every receptor just this we will be happy to answer so fast why do we need quite an extension I'm going to tell you my use case so approximately 1 year ago the Nuveen IPA were its recall is a new graphic API is that we have to replace opened in the near future so it's a load even and refugee you can create 3 per day games with it and its course compatible with Windows Linux and on the right but it's same I was enjoying opened in developments and the ways we call ISO and opportunities to improve mice Reading knowledge a node of an knowledge welcome frozen you can in so the ways that the you can have the system there are like segmentation of and was because it can be very optic tract segmentation efforts by going to get can but it's the is a difficult task that you want on July and can assure you yeah so to write about an extension in you have to make use of the c Pathan API it arrows you to create modules and other functions and classes things so after reading is a very good debate and a I stuck my C extension it was clear that fits its confidence but it's this is we have to fight again OK free like user but because it's too easy see beta Napier adds the reference contained in the cumbersome EPA right and was developed several times due to the amount of French so now we're going to see the exact existing solutions to revert to reserve the complexity of C extension but because of its let's see the ABI and API the from no I will often use ABI and API worlds so I need to explain clearly what they mean by stands it they PA means implication programming in and a maybe legation venerate inteface the a game is what you humans use when you got a function you need to know the name of the function and argument the bus so as a programming interface it's got expressed in cells cut it's a BA is very similar sink of it as a combined version of k to be clear when you write a program you use a you manipulate then when your program is called by computer when X is it a variance of the reverse maybe you want does a good adds a game but from a human point of view we could we could just take was that it came out but accessing worry we say BA model at o you to dynamically link at runtime and thus can be used inside interpreted longer than originally beta combination and so I get sort B model can be interesting to use you have to explicitly man binary interface that if so let's use an existing solutions to is you write bite an extension like a said just before or you can do it was this effect and see a again but it's a difficult task the 1st 1 is safe and like you may know I think you use an interesting approach he can executes Gericke your patent co that and you can add new syntaxes that immense by iteration it's very good but I think you can see on the screen when you stop to a distant site in some flex your by Tonka his numb operating in so you responsibility and Satan becomes a reprise of the you should take that into account before using it such a high dependency can be dangerous so it more the 1st goal of Satan is to improve performance of light and the to rock see very can be combined and those supports again and again and as a solution when no is see that is of rich it's a very good point because you can be sure satieties Auroi's development we see that you don't need computation it what's on the ends of a game of you dynamically linked 2 a very doing on but that you can see on-screen to that you need to learn a new you have to translate you see there was a suspect speaking in this example I declare the constant and get bags of ictal size function from my CD like you can see it's there are prominent chemist and the short of very big it would be buying food and it would lead you to signal mentioned votes because of mismatching and yet yeah and those a
that Sears 7 years ago to very very smart people and I mean the government said the jovsky created if if the you may know this names perturbed by by 2 says that the
Pacific for information by by the reason that at MIT bites and interpreter was adjacent so at 1st see if if I was an entity
to see it was rocking onions a game of
later on so API mother was viewed and were revolutionized bite an extension of the system the if if I 2 crates and API mud extension for beaten you have to use a supernatant CAPS and all and which that's a fan was working on is to think we see if if extension our team we suspect into 3 and by by without changing 1 line of future that could have no you understand the data in a P I can show you how we trucks we see if effect but just before that let's introduce and as a consequence of if if I this 1 is in the sombrero is and again came ins inland models everything is such that every time you impartial by tone because these things that would defend 1 no you have a superset of compression and pursue the combination that produces is and what which your main program and then in fact of course in a mother is an event on the for ideas since the the aim of that would grant the but combination so let's see some examples this 1st example and show how to run with ABS and in England this is the 1st supported by certified and it's exactly what effect is that for so we can provide to see that like you can see we see if if I you just as a city there to see this and open your area that's all know no i K to run this just magic cipher present X is clean and intuitive yeah the judge said we said that medical amenities a versatile some of that the something so I would just show you as my them all the time in general ball and and well OK and this example
reserve was then none I wrote on diarist face which contains the printer function in the C C printer functions it please the by so to let's if affine this function I had to give each we see that is an I creates the shark arguments and I can pass it to the printer function and then I bring distinctiveness ringways 0 John Hume administrator that it works like it so I print resists it print that function that was abiding printed function the so thank you difference of so that you can see it's very simple to use from which is so
certainly goes 1 step further with its it came out in the sense that it's similar but you can notice a difference we must seek the Pacific time we use a set of tools function then you just as if if I to combine your model your patent extension is reversed fast and easy to
maintain resist again you can't have segmentation foot you to a mismatching today you can your pride netware writer moreover the other a common features like you can see you can repress users value by 3 that's that's fairly not go into detail and this video the to adjust the sample demo is a money the
missing of smart program was made that good but the let's continue so you
know it's a very interesting facts and draw attributing the street the
underlying respect and and the new Congress each like I said to you I created the recall repel directly in resisted vacancies if k but if any at today it's songs to arming Rego because when I showing my recall rubber on IIsi but it does mean you could then you could that use if if I and then explain the advantages of cipher it took them all to meet the new challenge right of Fig over about 0 we see if if I was worthy to residents of what In this sort of decision because I spend a lot of at the time of my references but differently made righteous I'm going to show you why it FIL like on generic we have statistics so the guy carries Eugen under functions and of strict and at of constants Mars and 5 tells online of good and just for the CC there and there is examined descriptor the so what encloses the gorgeous decaying brings you just madness as you can see resist members more than 60 through those and lines for degenerative suffice but then presented to have then it's whereas we simplify it's only since fair and clean bite to give you an idea with time it took me 1 once and for the simulation and only 2 weeks we see if if I this time is only in my spare time so I think it would have taken only when weeks but for time we see if effect and moreover when I got an event use you ungated I can fix in 1 hour of maximum because it's just and plain and simple this Russian was too difficult to maintain so I want to run In both of those cases use a generative because there were about like you use in lecture so is very big so Queneau's book physical bank account did a very good job was great Rockies become 47 source and you get contributes city to the devil respect to this picture from it provides an exam and finds that describes a kid so my general of Texas XML file as input and generative reporter as that put by doing a generic so I can if things are going 2 minutes when a new rationales API is worries so busy getting users that's 1st uh I road and bus examined definitions zeng layer generated so that a modern zeng I generated by Tom my dearest ginger to ginger 2 is a public engine icing through no at a very famous and so by title communities so passing is then was examined to the package he tries to the user item under very good to us and it's a matter of time without image so transforms your opportunities into your she can do bytes in dictionary so the 1st step is then we have a good that the modern is pass so we can proceed to the gender to complete I focus on in this that's because that's where the 2 modern defense what you see here is for the structure of the C extensions so we composite
latency extension was a year a face tension for the same work so that we what you see is that for the structure of the C extensions but you can see
that there are 2 munching crossings invert so to keep going to mend the name and I had to speak to that planar of observed with indicator because a you can see it's very huge but what is more important is the complexity of the cut but you can see it's huge moreover we seek out you have to manage memory you and this is very very error prone know the same thing with if if it's very different despite of its looks the but you see on-screen means and that's we synthesize I didn't mean to sink about archedictyon it was varied of use 41 file 1 more point specific but you don't have trust my want when I say so the value is better let's see it's connection and you will understand constant is your thoughts and was case of simple In see we just passed we just use a simple this effect on the again to a constant Trotman modular bets the there is a difference we have to take care of would survive take we see if if i it's just right and and it's dynamically by but only with constants you don't go far away makes that is too crude binding frustrates near the difficulty but in because there is most critical sense so there are classes which is similar we see bytes and you have to and then the new the bend in it gets from each member and I don't and that is a set so you can't with my work mice you refer you contradicts an object's after I is initialized you have to use Manech politically memory for your objects in the new in that humans for your objects in in it you have to process each parameter we see by communities function which can be tricky and in gets you have to convert this history to bite eject I can assure you that it takes me that of thing figure out how to properly do its that is so long that they country you an example screen we see if final it's frontal and see if if I and as far as object location in the nation I just use bank by 10 to under or strict in his in his mind civilization in the January way I repeat to be sure that you understand this generate new function what's called or my strict we see based in here in this that I showed you must be done from the strict and there and the other 3 teams of appointed when you will realizes benefits you just putting those suffice so what they showed you entered
here is the ABA murder this tries a fast and robust a game of no we're going to web C worry was that they carry a lot of flying my this model is robust and fast but you need combination by the way if you know emotional states of the brain we are going to work social is the force of throughout them by Google and you use ABT to combine genocidal ranch to secure the canary Jesus and purely formats that are used to create program for you grow future if you just do some through the development of new may know this language the so I users to greater an extension ways it became a user page user crater for their dedicated to see if if I that they named cipher favored and they recommend you to the so to keep a consideration of consensus so in this on the screen generously that edge contains jealousy function signatures and strip we just could be passed the media provided by Google and see the phi and that's it they don't need to to model it's in this case by Xinhua severely 4 . is used to generative by 10 extension so next we observe Batiatus for their containing a were Bell and training with decorative this at that we as a specific to us if if so the definition 1st make you see we 1st with content of the chest there and this physical to the see their function sets for the diffusion sometimes you need to worry right you'll be done but in that case is it uterus so clean that they can do it legs at specific flight so tree-lined and see the fine knows all too under this library is very beautiful as so no the reading parts with sister alliance with this if if I to combines the cells we that cleaning Colibri just combine into names extension Batiatus should us a combined is that that we have to combine it with the following this if if it that i don't show you all because it's not directly linked and related to see if if you can look at a given date every throughout the city the like you can see there is no sea invert we just this if if had to abide by from time position of survivor yeah again looks like magic so now we have to use it jointly our extension is with the but we remain dependent of cipher it means that for example if you want to press the point of the function you have to use the cipher failure you choose functions that's when using your value your users should happening to lose if if it's just a dependency so we are going to to write a smaller right and then especially this guy is located in specialist units and these are the the money to automatically when you in but you would have the so this is in effect so 1st we know that our extension specialist which contain action if you fight and neighborhood yours so that they might use contains more function and strict correlated to already rich and if you if you find is used to in deference we Sorribas that's it's a means of combining this just a function remember as a city prairie arrows you the complete jettisoned discovered so this is this function or function defined in our extension can be accessed through able to live objects we should take a look at the compiler and gender so this alignment we can't just pure thanks nature in of stream and see if if I wanted forest it's kinda and it it's more notes is bites and in trying to string must be bytes next we should ask the riddles of a point up to us we have to deceive a flight to quality to abide by tangent means that they can use it In May program was named by also using its so we 1st give directions of pointing and cement but we come directly copies of that that would bite and bite and because bites the light is emitted so we have to compute that to the by temporary by and perceived In subject we should take a look at that if if fighting on the move function it's very smooth presuming computes the function but directly invited so here I'm doing memory manipulation gently bytes so would that's good faith so in Venice see if if a provides a set of extension you just add on 3 if if a modern and your extension would be read by so that it's a good way to like a geometry so that's the example
I were generally so we can enjoy a resident let's play a simple game very simple and dispose of them all so like you would see if i musings on you change recall at the ways of the corpora and the Batiatus should also love up to call this genus of cut and put it inside the regression just so this is the game is written fully respecting and make use of the new chain reportedly the think so very very simple you have the impression that we can do in processing of the
FAA conditions is there I have to send to
rare especially % was 0 then this is the wouldn't exist so it is where comes the parameters of citified Amerigo and much it's Trajanoski few missing the look for all weight and community and the very but it been since the because I talked with as in this to the very nice and thank you so much for your included a rock you makes witness effects and and you deserve our respect thank you and thank so I hope that like me you and judges the before and there you need to use the seed agrarian all you need to improve performance of Chicago please think about synthesize and thank you for your attention and have a nice day and if you have questions but this but it are there have been questions and thank you for the talk just a quick 1 so the guy was going to write poetry because 3 it exploits the strings in Europe it is because it was the coolant about the devil was using Python 2 is correct with based 3 3 . 6 the 2 strings are past this
points what is the very the it all the thank you for the topic of this is this on interfacing to the order and you interface to the + + as well so draw inferior I think it's 1 this is that you can when you harvest herein because they should also mention of Caesar's because the theory you can do see that our final suppressed history and then you use user Christopher Q hi how about interface in an existing libraries that have has its own garbage collection and generate a very common because I didn't understand would personally
be coming to the class because of very specific then had a so cavity collection well you need to bring it into the continuity it's a
story like hi hi got it and whatever garbage collection is needed by by just the library you need to do it so there is no automatic prediction at the level of the fact that the hi how you there any specific made with handling callback functions of the uh reserve resolution observation there is really key to revoke go back to begin by a on the right we that the core of the issue going cable and by others I can generate an so we can they can of and making them a definitive but was it a failure with the right as while the animal question is do you write a jury much at all but that's antigens of left fj