Code Monkey home page Code Monkey logo

Comments (4)

om26er avatar om26er commented on June 5, 2024

Adding slots is a bit of a challenge here. for each property we set a "private" counterpart of it. So for a property timestamp we have a _timestamp that gets set to None in the constructor. Then the setter for timestamp also assigns to that internal property. So we would need to add both _timestamp and timestamp to the __slots__ tuple.

@oberstet is that desirable/expected ?

from cfxdb.

oberstet avatar oberstet commented on June 5, 2024

Good question! In a way, the general question actually is:

How to combine

  • (writable) properties
  • slots
  • type hints

in Python, and if that is useful / desirable in the first place. Let's first find the answer to that ..

from cfxdb.

meejah avatar meejah commented on June 5, 2024

Is the point of the _timestamp with @property versions to enforce "it must be of type X" when setting..? (e.g. here

)

from cfxdb.

oberstet avatar oberstet commented on June 5, 2024

the reason to have both _attribute and @property is so that _attribute is lazily caching the actual value from the DB as a python native type (on first access)


rgd the specific domain of walltime/timestamps (the example you linked): this has evolved in xbr db classes to:

that is, accessing offers[txn, offer_oid].timestamp returns a native np.datetime64 python object that will be stored in object._timestamp upon first access.

there have been a handful reason why it has evolved into that (could expand if of interest) .. the example you linked is not xbr, but from event store (wamp event persistency), and this predates the xbr stuff where "timestamp" has evolved. another example is UUID - also #38

from cfxdb.

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.