jima80525 / ctypes_example Goto Github PK
View Code? Open in Web Editor NEWCode associated with an upcoming blog post discussing ctypes and python bindings in general
License: MIT License
Code associated with an upcoming blog post discussing ctypes and python bindings in general
License: MIT License
This calling of the wrapper functions and assignment to the instance on every new point instantiation just looks bad. It is not that bad, as the wrapped functions are not new objects, but it remakes the assignment to the unique func
in the ctypes wrapper for the library (although it would still have a major impact would one write actual Python code dealing with a couple hundred of Point instances)
I'd suggest just making the wrap call once, on top level code, would be much more elegant here:
class Point(...):
...
def move(self):
Point._move_point_func(self)
# These assignments must be after class body, due to the needed referenc to the class itself.
Point._move_point_func = wrap_function(lib, 'move_point', None, [Point])
...
(I am not sure if the functions wrapped by ctypes have a proper __get__
. If they have, you might not even need the intermediate move
method)
Good to see you fixed the __init__
for your point wrapper. I was reading the post, and upon finding the attribution self = get_point()
here, I came here to file the bug at once. :-)
self
is just a normal variable inside a method, and attributing to it will just make it point to another object, not "self" anymore.
Currently, MapGetter naively replaces the builtin __import__
inside the with
block. The existing import hooks seems to offer ways to make that in a cleaner way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.