<commit_before># -*- coding: utf-8 -*-

import ioport

class Connection(object):
    """ Connection class for IPFBlock
    
        Connection binding OPort and IPort of some IPFBlocks 
    """


    def __init__(self, oport, iport):
        # Check port compatibility and free of input port
        if ioport.is_connect_allowed(oport, iport):
            self._oport = oport
            self._iport = iport
            self._oport.increase_binded_count()
            self._iport.set_binded()
        else:
            raise ValueError("Can not create Connection with given ports")
            
    def __del__(self):
        self._oport.decrease_binded_count()
        self._iport.set_free()
        
        
    def contains_port(self, port):
        return self._iport == port or self._oport == port
        
        
    def process(self):
        """ Send value from output port to input port """
        self._iport.pass_value(self._oport.get_value())
        
        <commit_msg>Change _oport and _iport to weakref for prevention of loop references<commit_after># -*- coding: utf-8 -*-

import ioport
import weakref

class Connection(object):
    """ Connection class for IPFBlock
    
        Connection binding OPort and IPort of some IPFBlocks 
    """


    def __init__(self, oport, iport):
        # Check port compatibility and free of input port
        if ioport.is_connect_allowed(oport, iport):
            self._oport = weakref.ref(oport)
            self._iport = weakref.ref(iport)
            self._oport().increase_binded_count()
            self._iport().set_binded()
        else:
            raise ValueError("Can not create Connection with given ports")
            
    def __del__(self):
        self._oport().decrease_binded_count()
        self._iport().set_free()
        
        
    def contains_port(self, port):
        return self._iport() == port or self._oport() == port
        
        
    def process(self):
        """ Send value from output port to input port """
        self._iport().pass_value(self._oport().get_value())
        
        
{'fraction_non_alphanumeric': 0.09382479655337482, 'fraction_numerical': 0.0009573958831977022, 'mean_word_length': 2.024602026049204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5605107', 'n_tokens_mistral': 580, 'n_tokens_neox': 589, 'n_words': 158}