Code Monkey home page Code Monkey logo

Comments (3)

jab avatar jab commented on August 12, 2024

The undocumented...

Thanks for flagging this. invert used to be documented, but its docstring was removed when bidict's doctests were ported to external files. (This particular one ended up here.)

naive use of this method could cause significant confusion about what state a bidict is in at what point in a program

(Not moved much by this point. By analogy, we have reversed(my_list) as well as my_list.reverse(); up to the caller to use responsibly.)

...who wanted to do an in-place replacement of values...

Instead of the snippet you give above, this is a cleaner way to replace a bidict with its inverse:

>>> b = b.inv

Since this communicates the intention just as clearly as b.invert(), and is no less efficient than what invert was doing under the hood, I agree there's no reason to keep the invert method. Removed in d7551db. Thanks for the suggestion.

(Background: I work on a very large project (thousands of developers)

Are you using bidict in your very large project? Always curious to hear more about my users' use cases, in case you'd like to share. And if bidict is helping you in work you're getting paid for, please consider supporting bidict with a monetary contribution or asking your employer to do the same!

https://github.com/jab/bidict/blob/master/CONTRIBUTING.rst#other-ways-to-contribute

from bidict.

lordmauve avatar lordmauve commented on August 12, 2024

b = b.inv doesn't change an object in-place (such that existing references to it are updated).

We're not using bidict at this point. I'm just considering whether I can make a recommendation for its inclusion in the project and flagging up some issues that I would expect people to bring up. Due to the size of the project we end up being extremely careful about what we include, and a lot of questions get asked before any action would be taken.

from bidict.

jab avatar jab commented on August 12, 2024

b = b.inv doesn't change an object in-place (such that existing references to it are updated).

Yes, thank you. Meant to say, this must be done for every reference to b.

...I'm just considering whether I can make a recommendation...

Gotcha. I'm interested to discuss any other concerns, and hope bidict can accommodate your use case. Thanks again for your thoughtful feedback.

from bidict.

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.