Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement by using ctypes #15

Closed
sly8787 opened this issue Mar 31, 2018 · 1 comment
Closed

Performance improvement by using ctypes #15

sly8787 opened this issue Mar 31, 2018 · 1 comment

Comments

@sly8787
Copy link

sly8787 commented Mar 31, 2018

Hi,
I had the idea to integrate ctypes/Structure. I imagined that somehow:

  1. Get the meta data of the collection (field -> type)
  2. Build a object template by mongodb -> ctypes mapping definition
  3. Use the ctypes object template to construct the objects

I've already started my own experiment and I have to say that the performance gain is enormous:

class Attribute(Frame):
    __metaclass__ = ctypes.Structure
    _collection = 'system_attribute'
    _fields = {
        'key',
        'label',
        'description',
        'metadata',
        'field_class',
        'multivalue',
        'tags',
    }

    _fields_ = [
        ('key', ctypes.c_char),
        ('label', ctypes.c_char),
        ('description', ctypes.c_char),
        ('field_class', ctypes.c_char),
        ('multivalue', ctypes.c_bool),
        ('tags', ctypes.Union),
    ]

Let me know what you think

@sly8787 sly8787 closed this as completed Apr 5, 2018
@anthonyjb
Copy link
Member

Hi @TheGent sorry I haven't gotten around to replying yet, I am still intending to review your example, I'm very interested in the performance improvements you mentioned. Is there a reason you've closed the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants