Code Monkey home page Code Monkey logo

ctypes_example's People

Contributors

dbader avatar glubsy avatar jima80525 avatar paulc00 avatar sourcery-ai-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ctypes_example's Issues

creating uneeded instances

[ctypes.POINTER(Point)])

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)

hmm..fixed now

point = get_point()

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.

Change MapGetter to use import hooks

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.