Giter Site home page Giter Site logo

sanest's Introduction

sanest's People

Contributors

wbolster avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

sanest's Issues

weakref support

it is not possible to create a (direct) weak reference to a sanest.dict or sanest.list. this is just like their built-in dict and list counterparts.

for the built-in types, this can be "fixed" using a subclass, as outlined in the weakref docs:

Several built-in types such as list and dict do not directly support weak references but can add support through subclassing:

  class Dict(dict):
      pass
  obj = Dict(red=1, green=2, blue=3)   # this object is weak referenceable

since sanest.dict and sanest.list prevent subclassing, this trick won't work for us.

it is unclear to me whether this is a problem at all. feel free to chime in if you have valid use cases.

backport to python 2?

perhaps it makes sense, depending on demand.

(for the initial version(s) i wanted to avoid the complexity.)

typed list.__contains__

there should be a way to do a containment check on a list while also specifying the expected type. both the value and the type to be checked against come from the caller.

perhaps

l = sanest.list(['foo', 'bar'])
['foo', str] in l  # True
['foo', int] in l  # true

prevent subclassing?

it is a bad idea to subclass sanest containers, since it is very easy to complety break functionality and implied invariants, so perhaps it should just not be allowed. even consenting adults should adhere to it. ;)

read-only dict/list

it may be a nice idea to have a read-only version of a (nested) dict/list to avoid unintended modifications.

something like this perhaps?

d = sanest.dict(...)
ro = d.read_only()

ro would be a read-only view on d. (cf. types.MappingProxy from the stdlib).

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.