Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

One less function call.

One less function call when calling any rule in fmn.rules.  They almost all
have an ``@hint(...)`` decorator attached to them, which meant that
(unnecessarily) they all had one extra function call executed every time you
called them.

This cuts that out, and so should make everything *slightly* faster.
  • Loading branch information...
ralphbean committed Jun 21, 2016
1 parent ee2217b commit b4edbe1c6fcb700718f4278ae8e830c0fc8ac12e
Showing with 7 additions and 14 deletions.
  1. +7 −13 fmn/lib/hinting.py
  2. +0 −1 setup.py
@@ -15,7 +15,6 @@
"""

import collections
import decorator

import fedmsg.config

@@ -26,19 +25,14 @@
def hint(invertible=True, callable=None, **hints):
""" A decorator that can optionally hang datanommer hints on a rule. """

@decorator.decorator
def wrapper(fn, *args, **kwargs):
return fn(*args, **kwargs)
def wrapper(fn):
# Hang hints on fn.
fn.hints = hints
fn.hinting_invertible = invertible
fn.hinting_callable = callable
return fn

def wrapper_wrapper(fn):
wrapped = wrapper(fn)
# Hang hints on the wrapped function.
wrapped.hints = hints
wrapped.hinting_invertible = invertible
wrapped.hinting_callable = callable
return wrapped

return wrapper_wrapper
return wrapper


def prefixed(topic, prefix='org.fedoraproject'):
@@ -25,7 +25,6 @@ def get_description():
'fmn.rules',
'docutils',
'markupsafe',
'decorator',
'six',
]

0 comments on commit b4edbe1

Please sign in to comment.
You can’t perform that action at this time.