Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "pyrsistent in functional component" in Python

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'pyrsistent' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

def __new__(cls, message):
        return PClass.__new__(cls, message=message)
# Using ordinary set
    start = time.time()
    m1 = pmap(elements)
    print("Done initializing, time=%s s, count=%s" % (time.time() - start, COUNT))


    start = time.time()
    m2 = pmap()
    for x in test_range():
        m2 = m2.set(x, x)
    print("Done setting, time=%s s, count=%s" % (time.time() - start, COUNT))

    assert m1 == m2

    start = time.time()
    m3 = pmap()
    e3 = m3.evolver()
    for x in test_range():
        e3[x] = x
    m3 = e3.persistent()
    print("Done evolving, time=%s s, count=%s" % (time.time() - start, COUNT))

    assert m3 == m2

    start = time.time()
    m4 = pmap()
    m4 = m4.update(elements)
    m4 = m4.update(elements)
    print("Done updating, time=%s s, count=%s" % (time.time() - start, COUNT))

    assert m4 == m3
application_name = random_name(self)

            docker_client = DockerClient()
            self.addCleanup(docker_client.remove, application_name)

            deployer = P2PNodeDeployer(
                u"localhost", volume_service, docker_client,
                node_uuid=uuid4())

            link = Link(alias=u"alias",
                        local_port=80,
                        remote_port=8080)

            dataset = Dataset(
                dataset_id=unicode(uuid4()),
                metadata=pmap({"name": application_name}))
            manifestation = Manifestation(dataset=dataset, primary=True)
            desired_state = Deployment(nodes=frozenset([
                Node(uuid=deployer.node_uuid,
                     applications=frozenset([Application(
                         name=application_name,
                         image=DockerImage.from_string(
                             image_name),
                         links=frozenset([link]),
                         volume=AttachedVolume(
                             manifestation=manifestation,
                             mountpoint=FilePath('/data'),
                         ),
                     )]),
                     manifestations={
                         manifestation.dataset_id: manifestation})]))
def get_rrsets(self, zone_id):
        """
        Retrieve all the rrsets that belong to the given zone.

        @param zone_id: The zone to inspect.
        @type zone_id: L{unicode}

        @return: L{None} if the zone is not found.  Otherwise, a L{PMap}
            mapping L{RRSetKey} to L{RRSet}.
        """
        if any(zone.identifier == zone_id for zone in self.zones):
            return self.rrsets.get(zone_id, pmap())
        # You cannot interact with rrsets unless a zone exists.
        return None
def create_attached_volume(dataset_id, mountpoint, maximum_size=None,
                           metadata=pmap()):
    """
    Create an ``AttachedVolume`` instance with the supplied parameters and
    return it.

    :param unicode dataset_id: The unique identifier of the dataset of the
        attached volume.
    :param bytes mountpoint: The path at which the volume is attached.
    :param int maximum_size: An optional maximum size for the volume.

    :return: A new ``AttachedVolume`` instance referencing a primary
        manifestation of a dataset with the given unique identifier.
    """
    return AttachedVolume(
        manifestation=Manifestation(
            dataset=Dataset(
                dataset_id=dataset_id,
COUNT = 100000
    def test_range():
        prime = 317
        return range(0, prime*COUNT, prime)

    elements = {x: x for x in test_range()}

    # Using ordinary set
    start = time.time()
    m1 = pmap(elements)
    print("Done initializing, time=%s s, count=%s" % (time.time() - start, COUNT))


    start = time.time()
    m2 = pmap()
    for x in test_range():
        m2 = m2.set(x, x)
    print("Done setting, time=%s s, count=%s" % (time.time() - start, COUNT))

    assert m1 == m2

    start = time.time()
    m3 = pmap()
    e3 = m3.evolver()
    for x in test_range():
        e3[x] = x
    m3 = e3.persistent()
    print("Done evolving, time=%s s, count=%s" % (time.time() - start, COUNT))

    assert m3 == m2
def test_add_meta_with_defaults(self, registry, mock_meta):
        from pyrsistent import freeze
        standard_meta = freeze(mock_meta.return_value)\
            .transform(['states', 'draft', 'acm', 'principals'], ['role:moderator'])
        registry.content.workflows_meta['standard'] = standard_meta
        mock_meta.return_value = {'defaults': 'standard'}
        self.call_fut(registry, 'package:dummy.yaml', 'dummy')
        meta = registry.content.workflows_meta['dummy']
        assert meta['states'] == standard_meta['states']
        assert meta['transitions'] == standard_meta['transitions']
        assert meta['initial_state'] == standard_meta['initial_state']
        assert meta['defaults'] == 'standard'
def test_new_elements_created_when_missing():
    m = freeze({})
    assert m.transform(['foo', 'bar', 'baz'], 7) == {'foo': {'bar': {'baz': 7}}}
def test_multiple_transformations():
    v = freeze([1, 2])
    assert v.transform([2, 'foo'], 3, [2, 'foo'], inc) == freeze([1, 2, {'foo': 4}])
def test_add_meta_with_defaults_state_add_permission(self, registry,
                                                         mock_meta):
        from pyrsistent import freeze
        standard_meta = freeze(mock_meta.return_value)\
            .transform(['states', 'draft', 'acm', 'principals'], ['role:moderator'])
        registry.content.workflows_meta['standard'] = standard_meta
        mock_meta.return_value =\
            {'defaults': 'standard',
             'states': {'draft': {'acm': {'permissions':[['new', 'Added']]}}
             }}
        self.call_fut(registry, 'package:dummy.yaml', 'dummy')
        meta = registry.content.workflows_meta['dummy']
        assert meta['states']['draft']['acm']['permissions'] ==\
               [['view', 'Deny'],
                ['new', 'Added']]

Is your System Free of Underlying Vulnerabilities?
Find Out Now