A method is provided for operating a heat pump laundry dryer or a heat pump washing machine having drying function. The laundry dryer or washing machine includes: a control unit controlling the operation of the laundry dryer or washing machine, a laundry treatment chamber for treating laundry using process air, a process air circuit for circulating the process air, a heat pump system having a refrigerant loop, in which the refrigerant fluid is circulated through a first and a second heat exchanger, a compressor for circulating the refrigerant fluid through the refrigerant loop, and a cooling fan unit (24) for cooling the compressor. The method includes: modifying or changing an operation parameter set of the cooling fan unit (24) in dependency of at least one of the following input variables: a user selectable input variable, a working parameter of the laundry drum, a working parameter of a process air fan, a working parameter set meter of an electric driving motor, a working parameter of the compressor, a dr