Code Monkey home page Code Monkey logo

Comments (4)

1st1 avatar 1st1 commented on May 10, 2024 1

We considered having __getattr__ instead of __getitem__ but decided against that, because:

  1. There are a few methods in the Record object, such as .keys(), .values() etc. We don't want field names to clash with Record's API.
  2. Having both __getattr__ and __getitem__ doing the same thing feels non-pythonic.

from asyncpg.

runfalk avatar runfalk commented on May 10, 2024

Couldn't this and #17 be solved using a way of specifying an alternative Record class, or factory function, to use? This way the user could even use namedtuples if so desired for memory efficiency.

from asyncpg.

1st1 avatar 1st1 commented on May 10, 2024

Record is as memory efficient as Python's tuple (it's implemented in pure C). It's also faster than namedtuple to instantiate, since we have a freelist for it.

from asyncpg.

1st1 avatar 1st1 commented on May 10, 2024

I don't think we'll implement this. Adding __getattr__ will preclude us from adding methods/APIs to the Record class, so let's keep the status quo.

from asyncpg.

Related Issues (20)

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.