File: attrs_caching.py

package info (click to toggle)
pandas 0.23.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 167,704 kB
  • sloc: python: 230,826; ansic: 11,317; sh: 682; makefile: 133
file content (40 lines) | stat: -rw-r--r-- 779 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import numpy as np
from pandas import DataFrame
try:
    from pandas.util import cache_readonly
except ImportError:
    from pandas.util.decorators import cache_readonly

from .pandas_vb_common import setup  # noqa


class DataFrameAttributes(object):

    goal_time = 0.2

    def setup(self):
        self.df = DataFrame(np.random.randn(10, 6))
        self.cur_index = self.df.index

    def time_get_index(self):
        self.foo = self.df.index

    def time_set_index(self):
        self.df.index = self.cur_index


class CacheReadonly(object):

    goal_time = 0.2

    def setup(self):

        class Foo:

            @cache_readonly
            def prop(self):
                return 5
        self.obj = Foo()

    def time_cache_readonly(self):
        self.obj.prop