Skip to content

Idiomatic Python API #56

@rgov

Description

@rgov

Has any thought been given to developing an idiomatic Python API for Fast DDS? The API requires a coding style that is fairly unnatural in Python.

Some examples:

Accessing instance variables on objects:

# not idiomatic
data.message()
self.topic_data_type.getName()

# idiomatic
data.message
self.topic_data_type.name

Setting instance variables on objects:

# not idiomatic
data.message("Hello World")
self.topic_data_type.setName("HelloWorld")  # p.s., why does this one use "set" and other doesn't?


# idiomatic
data.message = "Hello World"
self.topic_data_type.name = "HelloWorld"

Passing objects by reference to have them initialized:

# not idiomatic
info = fastdds.SampleInfo()
data = HelloWorld.HelloWorld()
reader.take_next_sample(data, info)

# idiomatic
data, info = reader.take_next_sample()


# not idiomatic
self.subscriber_qos = fastdds.SubscriberQos()
self.participant.get_default_subscriber_qos(self.subscriber_qos)

# idiomatic, kind of?
self.subscriber_qos = self.participant.create_subscriber_qos()
self.subscriber_qos = fastdds.SubscriberQos.create_from(self.participant)

Manual management of resources:

# not idiomatic
factory = fastdds.DomainParticipantFactory.get_instance()
self.participant.delete_contained_entities()
factory.delete_participant(self.participant)

# idiomatic, often happens implicitly
del self.participant

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions