Git Product home page Git Product logo

fin's People

Contributors

stestagg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jguyomard

fin's Issues

fin.cache.method on classmethods doesn't work as expected

When fin.cache.method is used on a classmethod, the cached values are shared between all subclasses in a non-stable fashion. For example:

class A(object):
  BAR = 1
  @classmethod
  @fin.cache.method
  def foo(cls):
    return cls.BAR

class B(A):
  BAR = 2

If the following code is then run:

print A.foo()
print B.foo()

then the output is:

1
1

If, however, this is run instead:

print B.foo()
print A.foo()

then the output is:

2
1

This is due to the naive way fin.cache stores cached values in the dict of the class. It will only create a new cache dictionary on the object if an existing one isn't found, this breaks even more thoroughly when classmethod caches and instance caches are mixed.

The obvious way around this is to interact with the dict attribute directly, unfortunately class objects use a 'dictproxy' object for their dict attribute, which doesn't allow item assignment directly, preventing such simple manipulation.

The approach that should work would be to /test/ for attribute presence by using "in" on the dict directly:

CACHE_KEY in obj.__dict__

rather than:

 hasattr(obj, CACHE_KEY)

And then to use setattr() to write the new cache if this test fails.

Exception module

Does this have a use?

It is honestly just a single class, called Exception, which inherits Pythons Exception, and then does absolutely nothing.

This looks like a big waste of time and just obfuscates what it actually is when you could just use Python's standard Exception class.

Sorry if this isn't welcome! I just came to take a look from mu as I was interested in what fin is. Found the exception module quite curious.

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.