Code Monkey home page Code Monkey logo

slonik's Introduction

Slonik - An experiment from the past for the Python PostgreSQL driver of the Future

CircleCI

Rust Inside™

A Python binding to rust-postgres, a native PostgreSQL driver for Rust.

IRC channel: #slonik on freenode.

Note: Slonik started as an experiment, and will probably never go past that. We've learned tons of things during its creation, two of them being that programs using CFFI are bound to be slower (with CPython) than implementations using the Python C API, and that interfacing the Python Event Loop with the async support of Rust is… challenging at best.

slonik's People

Contributors

entwanne avatar k4nar avatar

Stargazers

 avatar  avatar  avatar

Watchers

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

Forkers

lqd

slonik's Issues

Add asynchronous support

The driver would be used in async Python environments, and then need to allow async calls on connections.

The rust driver has native asynchronous & pipelining support, we could find a way to benefit from them on Python side.

Reduce binding overhead

The performances of the current binding are bad due to multiple calls to the underlying driver, and multiple object instanciations on Python side.

e.g., for a list(Connection.from_env().query('SELECT a, b, c FROM foo WHERE d = $1 LIMIT 2', 'bar')) we have the following calls:

  • connect
  • new_query
  • query_param
  • query_exec_result
  • 2 times:
    • next_row
    • row_len
    • row_item (3 times)
    • row_close
  • result_close
  • close

Each call resulting in 2 new Python objects.

We could improve the binding to reduce the number of calls, by handling arrays instead of using only scalar types.
And we could avoid many Python objects as their interface is not exposed to the end-user.

License?

Hi:
what would be the license for this fine code?
Thanks!

Handle query parameter types

Currently, the driver handles int/float/str as Python input types, and int2/int4/int8/float8/text/bpchar/varchar/json/jsonb/uuid as PG output types.

It should handle all PG types, and conversions from standard Python types (as much as possible).

Memory leaks & consistency

The binding code uses a lot of unsafe sections to keep pointers alive hen returning them to Python.

There may be some places where these allocated resources are not correctly freed.
And other places where we may execute invalid operations on pointers that could result in segmentation faults.

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.