Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Optionally use __slots__ for payload members #259

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Commits on Nov 18, 2016

  1. Add option to use slots for struct payloads

    misakwa committed Nov 18, 2016
    Configuration menu
    Copy the full SHA
    942a89b View commit details
    Browse the repository at this point in the history
  2. Expose use_slots to load and load_fp

    - Expose using slot based generated code to load entry points
    - Add first tests
    - TODO:
        - Fix possible cache poisoning when loading slot vs no slot structs
        - Add tests for above
        - Add pickling tests for slot based structs
    misakwa committed Nov 18, 2016
    Configuration menu
    Copy the full SHA
    b490393 View commit details
    Browse the repository at this point in the history
  3. Clear cache before testing slots

    misakwa committed Nov 18, 2016
    Configuration menu
    Copy the full SHA
    8c6b369 View commit details
    Browse the repository at this point in the history
  4. Cache slot based objects with different keys

    misakwa committed Nov 18, 2016
    Configuration menu
    Copy the full SHA
    5f1f01e View commit details
    Browse the repository at this point in the history
  5. Move tests into test_hook.py

    misakwa committed Nov 18, 2016
    Configuration menu
    Copy the full SHA
    cc69f87 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2016

  1. Slot optimization

    - Replace class with a newer one with slot fields
    - Implement subclass and instance checks
    misakwa committed Nov 20, 2016
    Configuration menu
    Copy the full SHA
    9aa7a61 View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2016

  1. Rewrite class during creation with supported slots

    During the first creation of the loaded class with slots, a new class is
    inserted into the inheritance chain to ensure that the slot fields are defined.
    
    This is done because of the need to create an empty struct during the
    parsing phase and fill it in later - slots require the fields to be known before hand.
    
    All checks on the new replacement class will have it looking like the
    original except an equality comparison between the replaced class and
    its replacement.
    
    >>> import thriftpy
    >>> ab = thriftpy.load('addressbook.thrift', use_slots=True)
    >>> ab_inst = ab.AddressBook()
    >>> ab_inst.__class__ == ab.AddressBook # will return False
    >>> # all other checks should work as expected
    >>> isinstance(ab_inst, ab.AddressBook) # will return True
    >>> issubclass(ab_inst.__class__, ab.AddressBook) # will return True
    
    In order to get pickling to work as expected, a new extension type is
    registered with copyreg (copy_reg for py2x) to avoid pickling errors.
    misakwa committed Nov 22, 2016
    Configuration menu
    Copy the full SHA
    1a3b1bd View commit details
    Browse the repository at this point in the history
  2. fix service result slots

    misakwa committed Nov 22, 2016
    Configuration menu
    Copy the full SHA
    4032763 View commit details
    Browse the repository at this point in the history
  3. Add test for recursive type

    misakwa committed Nov 22, 2016
    Configuration menu
    Copy the full SHA
    afd9acd View commit details
    Browse the repository at this point in the history
  4. Fix recursive type test

    misakwa committed Nov 22, 2016
    Configuration menu
    Copy the full SHA
    65292c7 View commit details
    Browse the repository at this point in the history
  5. Remove stale comment

    misakwa committed Nov 22, 2016
    Configuration menu
    Copy the full SHA
    632c88e View commit details
    Browse the repository at this point in the history
  6. Fix TSPayload equality check

    misakwa committed Nov 22, 2016
    Configuration menu
    Copy the full SHA
    682e191 View commit details
    Browse the repository at this point in the history