Code Monkey home page Code Monkey logo

Comments (8)

SmithSamuelM avatar SmithSamuelM commented on September 22, 2024

Could you tell me what the issues are with Python3 support? Maybe I can port it.

from sophy.

pwharrison avatar pwharrison commented on September 22, 2024

+1 for Python3 support!

from sophy.

amirouche avatar amirouche commented on September 22, 2024

Make it happen 👍

from sophy.

coleifer avatar coleifer commented on September 22, 2024

Working on a rewrite which will work with py3 and also support the latest version 2.2. It's in a branch and I anticipate merging in the next day or so.

from sophy.

pwharrison avatar pwharrison commented on September 22, 2024

You are awesome. Looking forward to trying sophy in Python 3!

from sophy.

SmithSamuelM avatar SmithSamuelM commented on September 22, 2024

Fantastic =) 👍

from sophy.

coleifer avatar coleifer commented on September 22, 2024

Python3 support, as well as support for Sophia v2.2, has been merged into master and deployed on PyPI as sophy v0.2.0.

The APIs used for creating an environment / setting up a database have changed, so please refer to either the README or the test cases.

Quick overview:

from sophy import *

env = Sophia('/path/to/database-dir')

# Single key/value indexes
events_schema = Schema(
    key_parts=[U64Index('timestamp')],
    value_parts=[StringIndex('data')])
events = env.add_database('events', events_schema)

# Multi-field keys and values.
phonebook_schema = Schema(
    key_parts=[StringIndex('last_name'), StringIndex('first_name')],
    value_parts=[U16Index('area_code'), U64Index('number'), StringIndex('address')])
phonebook = env.add_database('phonebook', phonebook_schema)

env.open()  # Returns True

events[int(time.time()) - 7200] = 'finished up writing unit tests'
events[int(time.time()) - 3600] = 'rewriting the README'
events[int(time.time()) - 300] = 'closing out old github issues'
events[int(time.time())] = 'writing this as we speak...'

# What have I been doing in the last 10 minutes?
ten_min_ago = int(time.time()) - 600
for ts, data in events[ten_min_ago:]:
    print data

# Store some multi-field/multi-value data.
phonebook['cat', 'huey'] = (123, 5551234, '1337 Main St, Topeka KS')
phonebook['dog', 'mickey'] = (123, 5559123, '443 Apache Ct, Topeka KS')
phonebook['cat', 'zaizee'] = (123, 5554321, '000 Null St, Topeka KS')

print phonebook['cat', 'huey']
# (123, 5551234, '1337 Main St, Topeka KS')

# etc, etc.
env.close()  # True

from sophy.

SmithSamuelM avatar SmithSamuelM commented on September 22, 2024

Yippee!!!

from sophy.

Related Issues (15)

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.